Home » Community » Newbie corner » How to get rect of small square of OptionBox (Custom OptionBox Ctrl)
| How to get rect of small square of OptionBox [message #62062] |
Mon, 21 September 2026 07:24  |
DiaosLu
Messages: 5 Registered: July 2026
|
Promising Member |
|
|
I am making a custom OptionBox which change selection state only by clicking on the small square.
However, I cannot find how to get the Rect of square accurately, anyone can help?
|
|
|
|
| Re: How to get rect of small square of OptionBox [message #62064 is a reply to message #62062] |
Mon, 21 September 2026 19:01   |
Oblivion
Messages: 1284 Registered: August 2007
|
Senior Contributor |
|
|
Hi,
One way (usually something like this, if you want to build your own ctrl...)
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
Point pos = Null;
bool pressed = false;
Rect target = Null;
MyApp()
{
Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 400, 400);
}
void Paint(Draw& w) override
{
w.DrawRect(GetView(), Black());
w.DrawRect(target, pressed ? Green() : target.Contains(pos) ? Red() : White());
}
void Layout() override
{
Rect r = GetView();
target = r.CenterRect(r.GetSize() / 4);
}
void LeftDown(Point pt, dword) override
{
SetCapture();
pressed = target.Contains(pt);
Refresh();
}
void LeftUp(Point pt, dword) override
{
ReleaseCapture();
pressed = false;
Refresh();
}
void MouseMove(Point pt, dword) override
{
pos = pt;
Refresh();
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
TerminalCtrl package https://github.com/ismail-yilmaz/Terminal
|
|
|
|
|
|
Goto Forum:
Current Time: Tue Sep 29 16:21:58 GMT+2 2026
Total time taken to generate the page: 0.12839 seconds
|