RFC: new property in ToggleGroup

Michael Strauß michaelstrau2 at gmail.com
Sat Jan 21 16:32:53 UTC 2023


My expectation with radio groups is that they may start out initially
unselected, but once a selection has been made, no user interaction
can unselect all toggles again.
I don't see any compelling reason to change that. If the group needs
to be reset to its initial state, that's as easy as calling
`toggleGroup.selectToggle(null)`.

However, what you're describing sounds to me like a group of
checkboxes. I've seen this type of grouping many times in various
applications, and checkboxes are generally understood to be
deselectable.
So my question is: why don't we instead have CheckBox implement
Toggle, allowing it to be used with ToggleGroup? That would make it
possible to create a deselectable group of toggles.

On Fri, Jan 20, 2023 at 8:31 PM Andy Goryachev
<andy.goryachev at oracle.com> 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


More information about the openjfx-dev mailing list