DesktopRadioGroup size

I’m trying to calculate the size of a DesktopRadioGroup. Obviously I know what length the control is, as laid out in the IDE but with multiple languages I need to figure out the overall width.

I’m on macOS and I can’t seem to figure out a reason behind the spacing that comes with this control. Calculating the individual string lengths doesn’t cut it because the individual controls are spaced, in odd ways.

macOS declares welcome but I can’t use plugins. Here are some examples:

The spacing is not even, I’ve checked it with Photoshop. Nor are they as compact as they could be.

IIRC they’re just evenly spaced cells such that the full width is divided by 4. The space between the radio buttons themselves is probably the same.

The ultimate way to solve this if it’s only going to be on macOS would be to use auto layout, but I’m not sure that we’d be able to do that for just that control.

I can’t look at this in the morning but I’ll make a reminder to try something out in the afternoon if you still don’t have a solution.

Could you use a dropdown menu instead of the radio group?

Variablenname could be in upper case and Benutzerdefiniert doesn’t end with “es”.

1 Like

Sorry I should have said. The text isn’t real. It is an experiment using auto translate. Thanks for the pointers though.

I’m pretty sure the radio buttons are not equally spaced. I do have an idea I will try out a little later.

Well that didn’t work. There is a method of DesktopRadioGroup that returns each individual DesktopRadioButton. I thought why not retrieve the final one and look at the .Left of that. While it is true that you can retrieve them they location properties are not filled. Left = 0, Top = 0, Width = 0 and Height = 0. So much for that idea.

Here is an example that shows that the control doesn’t just space the items out evenly. Perhaps it evenly spaces all bar the last one.

I’ve not been able to understand or calculate the sizes required and have decided to take @Beatrix_Willius advice and swap to a popup menu. That has also allowed me to be more explicit over the meanings of the text I’m using.


The macOS has API for autosizing certain controls, it is possible you could autosize each radio button after setting the caption and then add the default 12 pixel gap between them.


You also have the possibility to add DesktopRadioButton without even using a DesktopRadioGroup. Then, while they’ll still be in a group (only one selected at once), their bound properties will work.
The autosizing declare which Sam recommends is still a great API provided by Mac OS that you may want to give a try.

Thanks guys. I’m aware of the DesktopRadioButton still being available. The group is easier in some ways. I think I was trying too hard to use radio options when a pop up menu works better.

1 Like

Wait… What?

Seems like I misunderstood a great deal of the conversion, I didn’t realize that Xojo was deciding the layout for you.

Seems all a bit Pete Tong to this ole programmer.

Yes, it has been an option for some time. DesktopRadioGroup allows you to automatically layout RadioButtons either horizontally or vertically as a single “control”. You provide the text like you do for a pop up menu and it does the rest. It also allows you to have more than one set on a window without wrapping them in a canvas or other container.

It has properties to allow you to set or read the selectedindex without testing each one in turn. It operates almost exactly like a DesktopPopupMenu. As Arnaud points out you can construct it in code by instantiating and adding DesktopRadioButtons to it.

You can still use the existing scheme.