Home » Community » Newbie corner » The Mysterious checkbox (I am positively confused by the Check box (a.k.a Option) control)
Re: The Mysterious checkbox [message #55567 is a reply to message #55562] |
Sun, 22 November 2020 09:07   |
Oblivion
Messages: 1206 Registered: August 2007
|
Senior Contributor |
|
|
Hello steveo,
Quote:To me a check box is a box that holds one of 2 states, either checked or not checked. It is useful to be able to respond to changes in check box state. I have spent the last hour looking over the 100 or so methods which seem to be associated with the check box and for the life of me I can't figure out how to call a method on that control which will tell me the state "checked or not checked".
Any ideas?
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyAppWindow : TopWindow {
Option option;
MyAppWindow()
{
Sizeable().Zoomable().CenterScreen().SetRect(0,0, 640, 480);
Add(option.SetLabel("Option").LeftPosZ(20).TopPosZ(20));
option << [=] { Title(Format("Option (checbox) state: %", ~option)); };
// OR,
// option.WhenAction = [=] { Title(Format("Option (checbox) state: %", ~option)); };
};
};
GUI_APP_MAIN
{
MyAppWindow().Run();
}
Almost all trivial ctrls (widgets) follow the same pattern. If they contain a Value you can access it via a tilde (~) operator,
Or via GetData and SetData methods. And they define a WhenAction callback which can be also set by an overloaded operator.
I suggest you check the Ctrl design concepts document:
https://www.ultimatepp.org/srcdoc$CtrlCore$CtrlDesignConcept s_en-us.html
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Sun, 22 November 2020 09:10] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat May 10 00:35:14 CEST 2025
Total time taken to generate the page: 0.02973 seconds
|