My radio buttons have ganged up on me

I have a small window with a groupbox on it (this is all API2, 2022R4.1 under Catalina). Inside the groupbox are five DesktopCheckboxes. These can be ticked and unticked independently, no problem. By contrast, however, I have a problem with the radio buttons, of which there are eight on the groupbox. They are arranged in pairs, thus giving four RadioGroup Sets. Each button shows in the Inspector as having index 0 or 1 and belonging to one of the four Control Sets. This shows as expected also if I use BBedit to look at the .xojo_window file for this small window, all looks correct.

Only one problem: these eight radiobuttons are acting as one group - only one of the eight shows as selected at a time. Click one from another Set and it selects and the previously selected one (even if in another Set) becomes de-selected. There’s no code that can be doing this, and the Sets have no event handlers.

I have tried:

  1. unparenting the radio-buttons. At the moment all eight have the groupbox as parent.
  2. turning off “Allow tab stop” for all eight

Neither of these actions made the slightest difference.

Each of the Sets (pairs of radio buttons) “belongs” to one of the checkbxes, and each pair is disabled/enabled according to whether the checkbox is ticked or not. This is done in code in the ValueChanged event for the corresponding CheckBox.

Any advice for getting these buttons to do as they’re told would be appreciated.

Radio buttons act based on their Parent. Each pair of radio buttons should have a separate parent, perhaps a canvas. Putting them in a control set makes no difference. It’s all about their parent control.

1 Like

So if I slide a canvas under each pair (so, four canvasses), and have each pair be parented by its own canvas, that will do it?


Well dash my wig. So what purpose do the sets serve, then?

In the case of radio buttons, none. In general, it allows you to have groups of controls that share a common set of events. Nothing more.

Right, I’ll get to it. Thanks for the clear explanation.

You can use the DesktopRadioButtonGroup which does operate completely separately without a parent. However, the layout can only be horizontal or vertical and the spacing is controlled by the Xojo. It operates as a single control no matter how many options you have within it

A RadioButtonGroup is not the same as adding a RadioButton and making a control set of them.

OK. I’ll give that a try next time.