Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1094
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


[Updated on: Sun, 22 November 2020 09:10]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Reliably converting between std::vector<uint8_t> and WString
Next Topic: check if application is running
Goto Forum:
  


Current Time: Mon Jun 17 02:10:27 CEST 2024

Total time taken to generate the page: 0.02307 seconds