<div dir="ltr">I don't see it being especially useful. GUI's tend to work this way. I remember it was the same in Swing.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 21, 2023 at 1:41 AM Kevin Rushforth <<a href="mailto:kevin.rushforth@oracle.com">kevin.rushforth@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<br>
<br>
<div>On 1/20/2023 2:57 PM, Andy Goryachev
wrote:<br>
</div>
<blockquote type="cite">
<div>
<p class="MsoNormal"><span>I just want to add one thing - the initial
state of
</span><span style="font-family:"Courier New",serif">RadioMenuItems
added to a menu is unselected, even if they belong to a
ToggleGroup.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>One can say that having all unselected
radio buttons in a toggle group makes no sense, or perhaps
it depends on the application requirements - though I cannot
find an example where it might be needed.</span></p>
</div>
</blockquote>
<br>
Yes, it's initially unselected unless the app makes an explicit
selection. HTML radio buttons work the same way [1]. Some apps use
that to indicate that nothing was selected, but then once you select
it there will always be something selected.<br>
<br>
<br>
<blockquote type="cite">
<div>
<p class="MsoNormal"><span><u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>So either we allow two different policies
by adding a property to the ToggleGroup, or we proclaim that
adding a radio button to a toggle group must have a side
effect of one (first) button to be automatically selected,
otherwise the whole group is in inconsistent state (or the
app developer must write some code to select one).</span></p>
</div>
</blockquote>
<br>
I wouldn't want to change the default behavior, since I can imagine
some apps relying on being able to tell if the user has ever
selected any of the choices.<br>
<br>
Having two properties would be one solution, presuming we think that
we need to provide a way for the app to indicate that it wants us to
enforce the invariant of ensuring that the app can't ever get the
control in a state where nothing is selected. Although, since it
would be an opt-in, the app could just as easily set the default
itself as opposed to setting this new property.<br>
<br>
-- Kevin<br>
<br>
[1]
<a href="https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_radio" target="_blank">https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_radio</a><br>
<br>
<blockquote type="cite">
<div>
<p class="MsoNormal"><span><u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>-andy<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">openjfx-dev
<a href="mailto:openjfx-dev-retn@openjdk.org" target="_blank"><openjfx-dev-retn@openjdk.org></a> on behalf of Kevin
Rushforth <a href="mailto:kevin.rushforth@oracle.com" target="_blank"><kevin.rushforth@oracle.com></a><br>
<b>Date: </b>Friday, 2023/01/20 at 12:27<br>
<b>To: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>
<a href="mailto:openjfx-dev@openjdk.org" target="_blank"><openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>Re: RFC: new property in ToggleGroup<u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12pt">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.<br>
<br>
What do other developers think?<br>
<br>
-- Kevin<br>
<br>
<u></u><u></u></p>
<div>
<p class="MsoNormal">On 1/20/2023 11:31 AM, Andy Goryachev
wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<p class="MsoNormal"><span>Dear colleagues:</span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span>In the context of a recent PR
</span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span><a href="https://bugs.openjdk.org/browse/JDK-8237505" target="_blank">https://bugs.openjdk.org/browse/JDK-8237505</a></span><u></u><u></u></p>
<p class="MsoNormal"><span><a href="https://github.com/openjdk/jfx/pull/1002" target="_blank">https://github.com/openjdk/jfx/pull/1002</a></span><u></u><u></u></p>
<p class="MsoNormal"><span><a href="https://stackoverflow.com/questions/57911107/javafx-togglegroup-not-functioning-properly-with-accelerators-radiomenuitem" target="_blank">https://stackoverflow.com/questions/57911107/javafx-togglegroup-not-functioning-properly-with-accelerators-radiomenuitem</a></span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span>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.</span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span>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.</span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span>This should allow for more flexibility in
creating menus with RadioMenuItems, but eliminate some
boilerplate code required in such cases.</span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span>The new logic would also affect any
Toggle, such as ToggleButton.</span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span>What do you think? Thank you.</span><u></u><u></u></p>
<p class="MsoNormal"><span> </span><u></u><u></u></p>
<p class="MsoNormal"><span>-andy</span><u></u><u></u></p>
</blockquote>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</blockquote>
<br>
</div>
</blockquote></div>