Index: src/org/netbeans/core/windows/frames/ShortcutAndMenuKeyEventProcessor.clazz Binary files src/org/netbeans/core/windows/frames/ShortcutAndMenuKeyEventProcessor.clazz.orig and src/org/netbeans/core/windows/frames/ShortcutAndMenuKeyEventProcessor.clazz differ Index: src/org/netbeans/core/windows/frames/ShortcutAndMenuKeyEventProcessor.java --- src/org/netbeans/core/windows/frames/ShortcutAndMenuKeyEventProcessor.java +++ src/org/netbeans/core/windows/frames/ShortcutAndMenuKeyEventProcessor.java @@ -55,28 +55,10 @@ if (ev.isConsumed()) return false; - KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ev); - Window w = SwingUtilities.windowForComponent(ev.getComponent()); - - if (!isTransmodalAction(ks) - && (w instanceof Dialog && ((Dialog)w).isModal()) - ) { - return false; - } - - // Provide a reasonably useful action event that identifies what was focused - // when the key was pressed, as well as what keystroke ran the action. - ActionEvent aev = new ActionEvent( - ev.getSource(), ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)); - - Keymap root = TopManager.getDefault ().getGlobalKeymap (); - Action a = root.getAction (ks); - if (a != null && a.isEnabled()) { - TopManager.getDefault().getActionManager().invokeAction(a, aev); - ev.consume(); + if (processShortcut(ev)) return true; - } + Window w = SwingUtilities.windowForComponent(ev.getComponent()); if (w instanceof Dialog) return false; @@ -118,6 +100,22 @@ MenuElement[] arr = MenuSelectionManager.defaultManager().getSelectedPath(); if (arr == null || arr.length == 0) { wasPopupDisplayed = false; + + // XXX(-ttran) special case for Shift+F10 on braindead Windoze. + // Shortcuts are handled in postProcessKeyEvent() so that the + // focused components can decide to handle and consume the key + // event itself. Buttons' and labels' mnemonics in components will + // work even though they conflict with shortcuts. But if we do so + // for Shift+F10 on Windoze then for some mysterious reason the + // system menu (left-upper icon in the native window caption) will + // be invoked, no matter how hard we try to consume the event. + + if (Utilities.isWindows() + && ev.getModifiers() == InputEvent.SHIFT_MASK + && ev.getKeyCode() == KeyEvent.VK_F10 + ) { + return processShortcut(ev); + } return false; } @@ -141,6 +139,31 @@ ev.setSource(WindowManagerImpl.mainWindow()); } return ev.isConsumed(); + } + + private boolean processShortcut(KeyEvent ev) { + KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ev); + Window w = SwingUtilities.windowForComponent(ev.getComponent()); + + if (!isTransmodalAction(ks) + && (w instanceof Dialog && ((Dialog)w).isModal()) + ) { + return false; + } + + // Provide a reasonably useful action event that identifies what was focused + // when the key was pressed, as well as what keystroke ran the action. + ActionEvent aev = new ActionEvent( + ev.getSource(), ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)); + + Keymap root = TopManager.getDefault ().getGlobalKeymap (); + Action a = root.getAction (ks); + if (a != null && a.isEnabled()) { + TopManager.getDefault().getActionManager().invokeAction(a, aev); + ev.consume(); + return true; + } + return false; } private static boolean invokeProcessKeyBindingsForAllComponents(