How common a UI feature is being able to deselect the selected item in a ToggleGroup via the UI such that no item is selected? I don't normally see that in various apps or toolkits that I am familiar with. What I do see is that either a default item is selected or no item is selected initially (which is the one and only time that there will be no item selected), but in both case, once you make a selection, there is no way via the UI to deselect the current item. Absent a compelling need, I think the current behavior (once the fix for JDK-8237505 is integrated) is sufficient.

What do other developers think?

-- Kevin


On 1/20/2023 11:31 AM, Andy Goryachev wrote:

Dear colleagues:

In the context of a recent PR

https://bugs.openjdk.org/browse/JDK-8237505

https://github.com/openjdk/jfx/pull/1002

https://stackoverflow.com/questions/57911107/javafx-togglegroup-not-functioning-properly-with-accelerators-radiomenuitem

where a number of RadioMenuItems belonging to a toggle group are added to the menu, we might want to add a new property to the ToggleGroup which controls whether all items in a group can be deselected.

If this property is set, a selected radio menu item can be deselected via either keyboard accelerator or a mouse click.  If not, then not only this operation cannot be performed, but also the first item added to said ToggleGroup gets automatically selected.

This should allow for more flexibility in creating menus with RadioMenuItems, but eliminate some boilerplate code required in such cases.

The new logic would also affect any Toggle, such as ToggleButton.

What do you think?  Thank you.

-andy

Reply via email to