This is exactly how it's working in my case.MichaelFarthing wrote:Consider these radio buttons
Square
Rectangle
Triangle
Circle
Ticking square shuld clear triangle and circle but leave rectangle still checked.
In my apps ticking a radio sets a value and invalidates the screen.
In the succeeding draw each radio box checks its value (which it might of might not be sharing with others) to decide whether it is checked or not.
No need for any radio box to know whether the others exist or not!
Clicking a radio button will set a variable to its value and then cause a redraw of all widgets using that variable, then all radio buttons using that variable will automatically look checked/unchecked depending on which one has the matching value. They don't even know if they're checked, this is only done at draw time, and as far as the program is concerned, it just looks which value the variable has, not the states of the widgets.
Also for what's worth it, the widget manager doesn't even know whether it's a checkbox or a radio button or anything else. Yeah the layout passed by the program indicates the widgets directly, but after it goes through the parser that doesn't matter. The widget manager knows how it behaves (checkbox is TOGGLE, radio is SET), what variable it affects and its "ideal" value (i.e. what value the variable must have for the widget to look active), its boundaries on screen and how it looks. This means all widgets are using the same code... it seems to be making things easier in the long term. Also when a widget is triggered the loop returns back to the program (passing the ID and new value), so the program can act on it (if needed) and then return back to the loop.
For context:
- Checkbox
- Behavior: TOGGLE (toggles between 0 and 1)
- Ideal value: 1
- Inactive graphic: blank square
- Active graphic: checked square
- Radio button
- Behavior: SET (sets to ideal value)
- Ideal value: user specified
- Inactive graphic: blank circle
- Active graphic: checked circled