Skip to main content
danielafort
Inspiring
October 4, 2015
Answered

Proper way to group rows of radio buttons?

  • October 4, 2015
  • 1 reply
  • 2045 views

I'm trying to fix a menu problem on an open source plugin. The radio buttons were not put into groups so when one radio button is selected all the others disappear--though the selections are still saved.

I grouped each row and that solved the selection issue but the appearance isn't right. Note that there is now a darker background on each row and the spacing has increased so the options no longer fit in the space.

I looked through the code looking for something that might be setting the background but can't find anything. What should I be looking for?

This topic has been closed for replies.
Correct answer johnrellis

What seems strange to me is that the radio_button value is working properly but the UI doesn't show the radio button as being selected. Maybe that's a bug? The Windows users aren't reporting this issue. I don't have a Windows system to test this on so maybe it works fine on Windows? I'll see if I can get a Windows user to take a look at it and report back.


I don't completely understand the intricacies of radio buttons, but you do need to ensure that each set of buttons is in a separate container.  The SDK guide says:

Within a container, only one of a set of radio buttons should be selected. Selecting one button should deselect all others in the set. You must enforce this in the way you bind the button values. It is not automatic.

Further, the LR 6 SDK API reference says there is a difference between the behavior on Mac and Windows, which may account for the different behavior you're seeing:

As of version 6.0 of the Lightroom SDK, on Mac only, radio buttons with the same parent view will be automatically 'linked', i.e. checking one will clear all the others, as a result of a change in the underlying OS provided API. This should only be noticeable in a view construct where radio buttons are declared via the osFactory:row or osFactory:column method within the same parent view. If you wish to have more than two radio buttons in a row or column, use the osFactory:view method instead, with a place attribute ofhorizontal or vertical. Do not attempt to take advantage of OS X's automatic behavior, as the automatically changed radio button states will not necessarily be reflected in the property table to which the radio buttons' values are bound.


This also suggests putting each set of radio buttons in an osFactory:view() container, with a "place" property.

1 reply

johnrellis
Legend
October 5, 2015

You might try something like:

viewFactory:group_box {...background_color = LrColor ("white"), ...}

Don't know if it will work, but there are many undocumented properties you can provide to controls.

johnrellis
Legend
October 5, 2015

Also, instead of radio buttons, you could use a popup_menu(), which can be more space-efficient at providing multiple choices.

danielafort
Inspiring
October 6, 2015

I don't completely understand the intricacies of radio buttons, but you do need to ensure that each set of buttons is in a separate container.  The SDK guide says:

Within a container, only one of a set of radio buttons should be selected. Selecting one button should deselect all others in the set. You must enforce this in the way you bind the button values. It is not automatic.

Further, the LR 6 SDK API reference says there is a difference between the behavior on Mac and Windows, which may account for the different behavior you're seeing:

As of version 6.0 of the Lightroom SDK, on Mac only, radio buttons with the same parent view will be automatically 'linked', i.e. checking one will clear all the others, as a result of a change in the underlying OS provided API. This should only be noticeable in a view construct where radio buttons are declared via the osFactory:row or osFactory:column method within the same parent view. If you wish to have more than two radio buttons in a row or column, use the osFactory:view method instead, with a place attribute ofhorizontal or vertical. Do not attempt to take advantage of OS X's automatic behavior, as the automatically changed radio button states will not necessarily be reflected in the property table to which the radio buttons' values are bound.


This also suggests putting each set of radio buttons in an osFactory:view() container, with a "place" property.


I guess group_box works as a container but the hardwired appearance is sort of a bummer. Don't know if that counts as the "proper" way to group a row of radio buttons but it looks like we're running out of options to get this menu layout to look and work the same way on Mac and Windows. Are there any other "containers" that might work? I'm exploring popup_menu() -- does it support tooltips that the original developer spent so much time getting just right? Can't seem to find that in the documentation but it might be another undocumented feature?