The behavior on Windows is all over the place for different applications.  I tested a few I've got running:

Notepad, Notepad++, Eclipse:

- Alt-down: Shows mnemonics on menu bar
- Alt-up: Highlights file menu on alt release
- Alt-tab: Shows mnemonics but doesn't highlight menu when it loses focus; when returning, mnemonics still highlighted, but doesn't act on them as menu not selected

-> Looks buggy

Thunderbird / Opera / Firefox:

- Alt-down: nothing
- Alt-up: shows menu bar (it is hidden normally)
- Alt-tab: works as expected, no highlighting

-> Looks well behaved

Explorer / Excel / Wordpad:

- Alt-down: nothing
- Alt-up: shows mnemonics
- Alt-tab: works as expected, no highlighting

-> Looks well behaved

Visual Studio Code:

- Alt-down: Shows mnemonics on menu bar
- Alt-up: Highlights file menu on alt release
- Alt-tab: Shows mnemonics, but hides them once it loses focus; on return doesn't show mnemonics

-> Looks well behaved

Chrome / IntelliJ:

-> Looks well behaved, doesn't react to alt presses in any way

None of the applications tested reacted on a mnemonic key after regaining focus however, even though they may have them still highlighted (which I think is a bug).

In my opinion, the behavior of notepad/notepad++/eclipse is incorrect (they need to hide the mnemonics on focus lost, like Visual Studio Code does, but they don't).

There seems to be two correct ways of handling mnemonics in applications that use them, either:

a) shows mnemonics immediately on alt-down, but hide them on focus lost (if the alt-down becomes an alt-tab, or probably any other alt combination)

b) only show mnemonics on a naked alt-up

Ticket JDK-8090647 mentions a spec that has been updated, but I can't find it.  It also mentions that the behavior for JavaFX should be what I described in a), so I think this is a bug that can simply be fixed.

--John

On 10/02/2023 14:29, Pedro Duque Vieira wrote:
Hi,

I'm developing an application for a customer and it seems like we've been hit by: JDK-8090647 <https://bugs.openjdk.org/browse/JDK-8090647> (?)

Steps:

1 - press alt + tab to switch to another app
2 - press alt + tab again to switch to javafx app again
3 - type a key with an associated "mnemonic action" in the javafx app (no alt key being pressed)

4 - "mnemonic action" gets triggered even though it shouldn't

So the problem is that the alt seems to "stick" after the javafx app loses and regains focus (through alt + tab) .


I've tested this under Windows 10 and Windows 11.

This is problematic to us since our users often use the keyboard to interact with our app and the previous version of our app (built in a different language than Java) didn't have this problem.

--

Pedro Duque Vieira - https://www.pixelduke.com

Reply via email to