RadioGroup vs RadioButton Set

for Desktop, but it might not matter for this question.

How does one use RadioGroup?
There isn’t much info on the difference between the two. I gleaned one piece - RadioGroup can only be vertical or horizontal and probably not columns or rows. I didn’t find anything about adding other members.

To add additional items to the group simply click the pencil next to Initial value and add lines to the list.

RadioGroups have some advantages and some disadvantages:

Advantages:

  • Alignment is easy as you say either horizontally or vertically. No need to align the controls manually.
  • Self spacing, you can provide text for each item and they will automatically space for that text. Especially useful for multi language applications.
  • Easier to read. There is a single property of the group that reads which one is selected, rather than having to loop over each and check which is selected.
  • You can have two different RadioGroups on a window and they don’t interfere with each other. Each maintains its own selected item. With RadioButtons you have to place them on a different container to achieve this (such as a canvas).

Disadvantages:

  • You have little or no control over the actual spacing used. All choices must be located either along side or above each other.
  • You cannot disable individual members of the group
  • You cannot simply change the text of a RadioButton within the group at runtime, if you do it doesn’t resize to fit the new text.

I’m sure there are more, but those come immediately to mind.

You can still use the RadioButton, place a RadioGroup on the window and change it’s super to RadioButton. You then get the old style control you used to have.

2 Likes

Just in case it’s the Dream. Does that mean the RadioGroup exists in a RsdioButton Set?

The other way around. Each RadioGroup is a collection of RadioButtons.

Sigh

1 Like

A “Control Set” is a completely different concept. You can make a Control Set of any control type. For example you can of a “set” of TextFields, or RadioButtons. In a Control Set all the control share a name and are distinguished by an Index. The Index has to be an integer but doesn’t have to be incremental.

For example you could have a controls set of RadioButtons with Indexes of 10, 11, 20 and 21, which is why it is a set and not an Array. It would be accessed as MyRadioButton(10). They share a set of Methods and Events. Each of which is modified to include an Index parameter, that tells you which of the set the event is for.

Just to be clear, you could place a CheckBox on the Window and then change the Super to DesktopRadioButton, you would still end up with a DesktopRadioButton control, it doesn’t have to be a RadioGroup.

so they old but more flexible Radiobutton was taken out of the library and they basically hid it

As i always use API 1 even with new versions I was not aware of that.

That means most new users will think they can only use RadioGroups… and I wonder if that eventually means the demise of independently placeable radio buttons…

Losing UI design flexability is not a good thing…

-Karen

1 Like

I don’t think you will ever see the RadioButton class disappear. It is used by the RadioGroup for each of its options. So, other than having to fight the IDE to get the control it is unlikely to ever disappear as an option.

There is a request for the DesktopRadioButton control to be added back to the library, thumbs up if you want this returned:
https://tracker.xojo.com/xojoinc/xojo/-/issues/67289

Interesting. In 2022 R3, I’m not missing DesktopRadioButton. What are they talking about?

It’s not in the library for 2023r1.1… i have it open now and am looking at it.

-Karen

When DesktopRadioGroup was added DesktopRadioButton was removed from the library. You cannot simply drag one into your project. You have to work around it by dragging another control and changing its Super. The feature request is to return DesktopRadioButton to the library along with DesktopRadioGroup.

RadioButton can be used in more flexible ways than RadioGroup and it would be good to keep that flexibility.
https://tracker.xojo.com/xojoinc/xojo/-/issues/67289

3 Likes