I'm creating some custom buttons for my "kiosk" app. Some of them have to act like the options in an "option group", so when one is selected, all the others ones must be unselected. Also, i may want that in a group at least one option is always active.
Inspired by old C++Builder6 similar controls, my wxOptionButtons will have a property called "GroupIndex" which if set != 0 means that all the buttons in the same GroupIndex must "react" to selection events generated from other buttons of the same group.
The "immediate" way to do this i can think of is:
in the "click" event of the clicked wxOptionButtons, loop all the children of the button parent, check if they are wxOptionButton, check if they have the same GroupIndex, and finally deselect it.
There's a better way? like an event (carrying some "code" with it) that each container can "raise" and that all of his children have to (or could) react to?
Or an App or system event?
Other ideas?
(using wxWidgets 3.0.4 on Win7 and Debian, if this matters).
wxOptionButtons: how to make an "option group"? Topic is solved
Re: wxOptionButtons: how to make an "option group"?
Hi,
Isn't what you want is called wxRadioBox? And you are reinventing the wheel?
Thank you.
Isn't what you want is called wxRadioBox? And you are reinventing the wheel?
Thank you.
Re: wxOptionButtons: how to make an "option group"?
Well, some aspects are like the RadioBox, but mine are not radio buttons but graphical ones, and they have not to be in the same container (i mean: they could be on different branches in the hierarchy of a "main" container).
So there's not an "itemlist", there's not a "value" of the group. They're more a serie of "interconnected" buttons.
I don't think i'm reinventing the wheel.
So there's not an "itemlist", there's not a "value" of the group. They're more a serie of "interconnected" buttons.
I don't think i'm reinventing the wheel.
Re: wxOptionButtons: how to make an "option group"?
I did something similar once. In the custom button class i kept a static list of all radio buttons (button ctor added itself to the list, dtor removed). And when a radio button was clicked, i just iterated over the list and deselected all with the same group id.
Use the source, Luke!