<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I'm not sure if you are able to test this yourself, but I made a
fix for this problem.</p>
<p>You could potentially test it by copying the class
`javafx.scene.Scene` in your project (without changing the package
-- and if modules will allow it, I don't use them personally) and
then using this piece of code:</p>
<p> private void setWindowFocused(boolean value) {<br>
windowFocused = value;<br>
<br>
Node node = getFocusOwner();<br>
if (node != null) {<br>
node.setFocusQuietly(windowFocused,
focusOwner.focusVisible);<br>
node.notifyFocusListeners();<br>
}<br>
<br>
if (windowFocused && accessible != null) {<br>
accessible.sendNotification(AccessibleAttribute.FOCUS_NODE);<br>
}<br>
<br>
if (!windowFocused) {<br>
getInternalEventDispatcher().getKeyboardShortcutsHandler().setMnemonicsDisplayEnabled(false);<br>
}<br>
}</p>
<p>The last three lines are what I added. A quick test on Windows
here shows that the mnemonics get disabled as soon as the window
loses focus, and when returning, they're not responding as you'd
expect.</p>
<p>I'll submit a PR as well.<br>
</p>
<p>--John<br>
</p>
<div class="moz-cite-prefix">On 12/02/2023 15:52, Pedro Duque Vieira
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAAEud6ab8dkn9ivMrOBUB4A0sb6+3-GY54upgb7GsvxprDR9=Q@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The
behavior on Windows is all over the place for different<br>
applications.? I tested a few I've got running:</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Notepad,
Notepad++, Eclipse:</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">-
Alt-down: Shows mnemonics on menu bar<br>
- Alt-up: Highlights file menu on alt release<br>
- Alt-tab: Shows mnemonics but doesn't highlight menu when it
loses<br>
focus; when returning, mnemonics still highlighted, but
doesn't act on<br>
them as menu not selected</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">->
Looks buggy</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thunderbird
/ Opera / Firefox:</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">-
Alt-down: nothing<br>
- Alt-up: shows menu bar (it is hidden normally)<br>
- Alt-tab: works as expected, no highlighting</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">->
Looks well behaved</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Explorer
/ Excel / Wordpad:</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">-
Alt-down: nothing<br>
- Alt-up: shows mnemonics<br>
- Alt-tab: works as expected, no highlighting</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">->
Looks well behaved</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Visual
Studio Code:</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">-
Alt-down: Shows mnemonics on menu bar<br>
- Alt-up: Highlights file menu on alt release<br>
- Alt-tab: Shows mnemonics, but hides them once it loses
focus; on<br>
return doesn't show mnemonics</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">->
Looks well behaved</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Chrome
/ IntelliJ:</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">->
Looks well behaved, doesn't react to alt presses in any way</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">None
of the applications tested reacted on a mnemonic key after<br>
regaining focus however, even though they may have them still<br>
highlighted (which I think is a bug).</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In
my opinion, the behavior of notepad/notepad++/eclipse is
incorrect<br>
(they need to hide the mnemonics on focus lost, like Visual
Studio Code<br>
does, but they don't).</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">There
seems to be two correct ways of handling mnemonics in
applications<br>
that use them, either:</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">a)
shows mnemonics immediately on alt-down, but hide them on
focus lost<br>
(if the alt-down becomes an alt-tab, or probably any other alt
combination)</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">b)
only show mnemonics on a naked alt-up</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Ticket
JDK-8090647 mentions a spec that has been updated, but I can't<br>
find it.? It also mentions that the behavior for JavaFX should
be what I<br>
described in a), so I think this is a bug that can simply be
fixed.</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">--John</blockquote>
<div><br>
</div>
<div><br>
</div>
<div>Yap, there's quite different behaviors across apps. If you
test on windows 11 you'll get yet another set of different
behaviors.</div>
<div><br>
</div>
<div>But all in all, if you: alt+tab (without release) and
alt+tab again so your app regains focus, you'll have the
mnemonic still activated, which, as you say, sounds like a bug
no matter the difference in behaviors across apps. <br>
<br>
I agree with your suggestion: "a".<br>
<br>
My client was quite disappointed and started to rant about
javafx. It didn't help that we were hit by a couple other bugs
(perhaps bad luck). The fact that the bug was filed on 2013
(10 years later) and is still happening can be quite
problematic. <br>
Perhaps it would make sense to review all bugs filed, giving
highest priority to the bugs that were submitted longer ago?<br>
<br>
Thanks!</div>
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>Pedro Duque Vieira - <a
href="https://www.pixelduke.com" target="_blank"
moz-do-not-send="true" class="moz-txt-link-freetext">https://www.pixelduke.com</a></div>
</div>
</div>
</div>
</blockquote>
</body>
</html>