This project is read-only.

Buttons state

Dec 30, 2011 at 11:45 PM



first i like to say its a awesome and very easy libary to work with however i got one problem i just cant sort out,

How can i read back the state of buttons or any other elements like if the are clicked or checked or changed position ?




Jan 1, 2012 at 5:15 AM
Edited Jan 1, 2012 at 5:15 AM

Glad you like it.

All elements have the below 3 properties. These can be used to get info about the state of the element. 




Some elements have extra properties for example the ToggleButton widget has the IsToggled property which returns true when the GUI is pressed. Widgets also have ElementEvents. These events allow you to attach code in the form of a delegate to a widget that will automatically be called when a even occurs.

Here is an example for the toggle button class. 

var car = new ToggleButton(130, 120, "Toggle");
car.OnToggle += delegate { Window.Title = "X"; };
car.OffToggle += delegate { Window.Title = "Y"; };

The delegate attached to the OnToggle and OffToggle events will automatically be invoked when ever the described action is taken. This prevents you from having to poll the state of the widget.

Hope that helps. The properties and the events should give you enough info and power to do what ever you need. If you find yourself needing more give me a heads up.


Hope That Helps,