On Thu, 22 Feb 2024 11:11:01 GMT, Abhishek Kumar <abhis...@openjdk.org> wrote:

> Menu mnemonic doesn't toggle between show and hide state when F10 is pressed. 
> Behavior is not similar to windows native application. Fix is to ensure that 
> menu mnemonic state toggles between show and hide.
> 
> Can be verified with SwingSet2 application. 
> CI tests are green with the fix. Link posted in JBS.

Swing does not implement hiding/showing mnemonics and focus indicators 
correctly, at least not in a way native Win32 app are supposed to behave. I'm 
unsure if there's a bug for it though.

> Notepad doesn't seem to toggle but Notepad++ and Word does so I guess it's ok 
> to behave similarly..

Notepad in Windows 11 uses WinRT API instead of classic Win32 API. For me, it 
shows mnemonics (F, E, V, S) but does not activate the menu.

Classic Win32 apps, including Notepad++, do show mnemonics when the menu bar is 
activated using Alt or F10.

I ran SwingSet2, switched it to Windows Look-and-Feel, and I can see the 
mnemonics on the menu items if activate the menu bar using F10.

After I read the description in 
[JDK-8326458](https://bugs.openjdk.org/browse/JDK-8326458), I understand it! 
You did not do the right thing. If you look closely at the native Win32 apps, 
you'll notice that F10 activates the menu bar, the focus goes to the first menu 
item. Pressing F10 for the second time, removes the focus from the menu bar, 
returning it to whatever control had focus before; as the result, menu 
mnemonics are removed from the menu bar. (What doesn't help is that Windows 11 
highlights the active menu item with a slightly darker colour, the effect is 
prominent on Windows 10 where the active menu is highlighted with a bluish 
color.)

In SwingSet2, pressing F10 for the first time activates the menu bar and 
displays the mnemonics as expected. *Pressing F10 for the second time does 
nothing.*

At the same time, pressing Alt key does the right thing. The first press of Alt 
activates the menu bar and displays the mnemonics, the second press of Alt key 
returns the focus to the component which had had the focus before Alt was 
pressed for the first time and removes the mnemonics from the menu bar.

Hiding the mnemonics is not enough.

*F10 should behave just like Alt key.*

Getting back to Notepad, it handles Alt key correctly but it fails to handle 
F10 key the same way.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17961#issuecomment-1965074756

Reply via email to