On Wed, 28 Feb 2024 16:40:03 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. > > Abhishek Kumar has updated the pull request incrementally with one additional > commit since the last revision: > > Handle F10 key press for focus and mnemonic This needs testing with popup menus and combobox popups. src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java line 152: > 150: path[0] = (MenuElement)menuBar; > 151: path[1] = (MenuElement)menu; > 152: if (!mnemonicShowHideFlag) { I don't think you need a field at all. The entire method should look like this: public void actionPerformed(ActionEvent e) { JMenuBar menuBar = (JMenuBar)e.getSource(); JMenu menu = menuBar.getMenu(0); if (menu != null) { MenuSelectionManager msm = MenuSelectionManager.defaultManager(); MenuElement[] selectedPath = msm.getSelectedPath(); if (selectedPath.length > 0 && (selectedPath[0] instanceof JMenuBar)) { msm.clearSelectedPath(); WindowsLookAndFeel.setMnemonicHidden(true); } else { MenuElement[] path = {menuBar, menu}; msm.setSelectedPath(path); WindowsLookAndFeel.setMnemonicHidden(false); } WindowsLookAndFeel.repaintRootPane(menuBar); } } If there's a selection path and it starts with the menu bar, clear selection and hide mnemonics. Otherwise, select the menu bar and its first menu. ------------- Changes requested by aivanov (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/17961#pullrequestreview-1906804650 PR Review Comment: https://git.openjdk.org/jdk/pull/17961#discussion_r1506296870