Button, RadioGroup and Value

It seems that now, each button can only be linked to a value as a boolean. Particularly in the case of radio groups, it seems that the button should actually be linked to a value plus ‘value of that value’. So for instance, a radio group of four buttons could be linked to one value and set it to 1,2,3 or 4 depending on which is switched.

A simple implementation now would involve a buttonlistener and value listener and specific code to hand link the controls? Or maybe a value bridge that links n boolean values to one integer value?


Looking around, if Button used var onValue, then get, set etc. could be compared to that instead of just treated as a boolean. The default for the var would be boolean-true, so it would be backwards compatible. Some methods would need overrides with a var instead of a bool.

If I make those changes Jules, would you wrap them in?


My approach to the problem would probably be to leave the buttons alone, but instead to create a special type of Value::ValueSource that takes a bunch of boolean Values (each attached to a button) and converts them to/from an integer or string result. That way all the logic for a group could be kept inside one class, and well away from any UI classes.

Huh, didn’t think of that. A ValueSource subclass that links to a set of Values? And which Value/bool is triggered determines the value?

I’ll have a go. The more I looked at it, BTW, the more reminded I was by a control program that let you create simple GUIs. Each button linked to a device parameter, and had a mode (relative or absolute) and an on and off value. That also made it easy to make up down buttons and the like.

Just seems like only one useful button being able to link to each Value might be missing out on a big benefit of Values - the slim amount of code needed. Even stuff like having a Slider and a ‘Unity’ button would be cool, or using buttons to set fixed int values.


You could make a VarButtonValueSource, upon which you could call addButton(button,someVar). This would take the buttons toggle state Value, and store it with the var it should give. Then, when getting the value from this ValueSource, you’d just return the stored var for the button Value which is currently true (you could also have a default ‘all off’ value, so it could easily be used for single button value switches.

Edit- of course you could make it more generic and just give it the values directly but i guess a button helper wouldn’t hurt :slight_smile: