<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Radio buttons are a very common UI control that are well
understood by users familair with UI's of the past decades, and
also for programmers reading the resulting state of the radio
buttons. Allowing deselection would be something users have not
seen before, and I'm sure every UI styleguide out there will
advocate against allowing this even if it were possible in the UI
toolkit of choice. Allowing deselection is also something
programmers have not seen before (did the user really select
nothing, or is it still in its default state?) Therefore, having
JavaFX support such a feature would be supporting something that
will probably be avoided by everyone making UI's that are easy to
understand by users.</p>
<p>I think we'd need to see more use cases, and also requests from
other users before considering such a feature. Even then it would
go against years of UI design and user familiarity with UI's on
practically every platform (it's amazing to be honest that almost
all platforms use the same concept for a group of choice of which
only one can be selected).</p>
<p>If a radio button group really needs a way to express "none of
the above", then another option can be added that does exactly
that.</p>
<p>--John<br>
</p>
On 23/01/2023 19:04, Andy Goryachev wrote:<br>
<blockquote type="cite"
cite="mid:DM5PR1001MB21725A3169C9AF92B5111B08E5C89@DM5PR1001MB2172.namprd10.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
{font-family:"Times New Roman \(Body CS\)";
panose-1:2 11 6 4 2 2 2 2 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Courier New",serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}div.WordSection1
{page:WordSection1;}</style>
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif">It is indeed the same in Swing: the initial
state for a ButtonGroup is all deselected. Kevin brought up
a good example with HTML radio buttons - in effect saying
that this initial state indicates that the user needs to
make a choice, which is the most frequent case in an HTML
page.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif">However, it may or may not be the case in
FX. Consider, for example, a case where a file viewer
presents a number of modes - (text | hex | image) to present
a file. These modes are mutually exclusive (thus requiring
RadioMenuItems or ToggleButtons), but one *must* be selected
initially, since it does not make sense to ask the user to
make a choice, instead a default choice must be made by the
application.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif">Yes, it can be simply solved by making a
default one selected in the code, and that is what is
usually done. I just thought that having a property would
eliminate extra code. One can also extend ToggleGroup to
provide that functionality, and that is what I have done in
the past.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif">Thank you all for the discussion and
insightful comments. Given the negative feedback and
availability of easy workaround I withdraw this RFC.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif">-andy<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Courier
New",serif"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span
style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Nir
Lisker <a class="moz-txt-link-rfc2396E" href="mailto:nlisker@gmail.com"><nlisker@gmail.com></a><br>
<b>Date: </b>Saturday, 2023/01/21 at 08:22<br>
<b>To: </b>Kevin Rushforth
<a class="moz-txt-link-rfc2396E" href="mailto:kevin.rushforth@oracle.com"><kevin.rushforth@oracle.com></a><br>
<b>Cc: </b>Andy Goryachev
<a class="moz-txt-link-rfc2396E" href="mailto:andy.goryachev@oracle.com"><andy.goryachev@oracle.com></a>, <a class="moz-txt-link-abbreviated" href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a>
<a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.org"><openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>[External] : Re: RFC: new property in
ToggleGroup<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I don't
see it being especially useful. GUI's tend to work this
way. I remember it was the same in Swing.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On Sat,
Jan 21, 2023 at 1:41 AM Kevin Rushforth <<a
href="mailto:kevin.rushforth@oracle.com"
moz-do-not-send="true" class="moz-txt-link-freetext">kevin.rushforth@oracle.com</a>>
wrote:<o:p></o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC
1.0pt;padding:0in 0in 0in
6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span
style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On
1/20/2023 2:57 PM, Andy Goryachev wrote:<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">I just want to add one
thing - the initial state of
</span><span
style="font-size:11.0pt;font-family:"Courier
New",serif">RadioMenuItems added to a menu is
unselected, even if they belong to a ToggleGroup.</span><span
style="font-size:11.0pt"><o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">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.<o:p></o:p></span></p>
</div>
</blockquote>
<p class="MsoNormal"><span style="font-size:11.0pt"><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>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">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).<o:p></o:p></span></p>
</div>
</blockquote>
<p class="MsoNormal"><span style="font-size:11.0pt"><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://urldefense.com/v3/__https:/www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_radio__;!!ACWV5N9M2RV99hQ!IHUhh-zd22k26dpWxaIMIQPWkUKslHglTRC3u7NgvYYyYi4ZLWiijdogZwo2f9iRPTRGkKW9kGAzk6Vz7Whx$"
target="_blank" moz-do-not-send="true">
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_radio</a><br>
<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">-andy<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"
style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><b><span
style="font-size:12.0pt;color:black">From:
</span></b><span
style="font-size:12.0pt;color:black">openjfx-dev
<a href="mailto:openjfx-dev-retn@openjdk.org"
target="_blank" moz-do-not-send="true">
<openjfx-dev-retn@openjdk.org></a> on
behalf of Kevin Rushforth <a
href="mailto:kevin.rushforth@oracle.com"
target="_blank" moz-do-not-send="true">
<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" moz-do-not-send="true"
class="moz-txt-link-freetext">openjfx-dev@openjdk.org</a>
<a href="mailto:openjfx-dev@openjdk.org"
target="_blank" moz-do-not-send="true"><openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>Re: RFC: new property in
ToggleGroup</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><span
style="font-size:11.0pt">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<o:p></o:p></span></p>
<div>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">On 1/20/2023 11:31 AM,
Andy Goryachev wrote:<o:p></o:p></span></p>
</div>
<blockquote
style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">Dear colleagues:<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">In the context of a
recent PR
<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"><a
href="https://bugs.openjdk.org/browse/JDK-8237505"
target="_blank" moz-do-not-send="true"
class="moz-txt-link-freetext">https://bugs.openjdk.org/browse/JDK-8237505</a><o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"><a
href="https://urldefense.com/v3/__https:/github.com/openjdk/jfx/pull/1002__;!!ACWV5N9M2RV99hQ!IHUhh-zd22k26dpWxaIMIQPWkUKslHglTRC3u7NgvYYyYi4ZLWiijdogZwo2f9iRPTRGkKW9kGAzkyU-UIVq$"
target="_blank" moz-do-not-send="true">https://github.com/openjdk/jfx/pull/1002</a><o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"><a
href="https://urldefense.com/v3/__https:/stackoverflow.com/questions/57911107/javafx-togglegroup-not-functioning-properly-with-accelerators-radiomenuitem__;!!ACWV5N9M2RV99hQ!IHUhh-zd22k26dpWxaIMIQPWkUKslHglTRC3u7NgvYYyYi4ZLWiijdogZwo2f9iRPTRGkKW9kGAzk5wy-flH$"
target="_blank" moz-do-not-send="true">https://stackoverflow.com/questions/57911107/javafx-togglegroup-not-functioning-properly-with-accelerators-radiomenuitem</a><o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">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.<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">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.<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">This should allow for
more flexibility in creating menus with
RadioMenuItems, but eliminate some boilerplate
code required in such cases.<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">The new logic would
also affect any Toggle, such as ToggleButton.<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">What do you think?
Thank you.<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt">-andy<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:11.0pt"> <o:p></o:p></span></p>
</div>
</blockquote>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</blockquote>
</div>
</div>
</blockquote>
</body>
</html>