From 501f9ce3b1e7e19fbca052d4201de74555664559 Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Thu, 17 Nov 2016 17:15:07 +0300 Subject: [PATCH] IDEA-47906 alt+i (shortcut to press the commit button) does not work on the commit dialog --- .../src/com/intellij/openapi/MnemonicHelper.java | 5 +---- .../src/com/intellij/openapi/ui/DialogWrapper.java | 2 +- .../openapi/keymap/impl/IdeKeyEventDispatcher.java | 8 +++----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/MnemonicHelper.java b/platform/platform-api/src/com/intellij/openapi/MnemonicHelper.java index aecd28684f3b..cf4ac1a50df2 100644 --- a/platform/platform-api/src/com/intellij/openapi/MnemonicHelper.java +++ b/platform/platform-api/src/com/intellij/openapi/MnemonicHelper.java @@ -151,10 +151,7 @@ public class MnemonicHelper extends ComponentTreeWatcher { */ public static CustomShortcutSet createShortcut(char ch) { Character mnemonic = Character.valueOf(ch); - String shortcut = SystemInfo.isMac && SystemInfo.isJavaVersionAtLeast("1.7") - ? "control alt pressed " - : "alt pressed "; - return CustomShortcutSet.fromString(shortcut + mnemonic); + return CustomShortcutSet.fromString("alt " + (SystemInfo.isMac ? "released" : "pressed") + " " + mnemonic); } /** diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index b3d34f097164..301b0f2174dd 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -750,7 +750,7 @@ public abstract class DialogWrapper { final char mnemonic = (char)eachInfo.getMnemonic(); JRootPane rootPane = getPeer().getRootPane(); if (rootPane != null) { - new DumbAwareAction() { + new DumbAwareAction("Show JBOptionButton popup") { @Override public void actionPerformed(AnActionEvent e) { final JBOptionButton buttonToActivate = eachInfo.getButton(); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java index 04897f4fe233..5751a73967cf 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java @@ -420,10 +420,8 @@ public final class IdeKeyEventDispatcher implements Disposable { if (SystemInfo.isMac) { boolean keyTyped = e.getID() == KeyEvent.KEY_TYPED; - boolean hasMnemonicsInWindow = (e.getID() == KeyEvent.KEY_PRESSED - || e.getID() == KeyEvent.KEY_RELEASED) - && hasMnemonicInWindow(focusOwner, e.getKeyCode()); - + boolean hasMnemonicsInWindow = e.getID() == KeyEvent.KEY_PRESSED && hasMnemonicInWindow(focusOwner, e.getKeyCode()) || + keyTyped && hasMnemonicInWindow(focusOwner, e.getKeyChar()); boolean imEnabled = IdeEventQueue.getInstance().isInputMethodEnabled(); if (e.getModifiersEx() == InputEvent.ALT_DOWN_MASK && (hasMnemonicsInWindow || !imEnabled && keyTyped)) { @@ -499,7 +497,7 @@ public final class IdeKeyEventDispatcher implements Disposable { private static boolean hasMnemonicInWindow(Component focusOwner, int keyCode) { if (keyCode == KeyEvent.VK_ALT || keyCode == 0) return false; // Optimization - final Container container = SwingUtilities.getWindowAncestor(focusOwner); + final Container container = UIUtil.getWindow(focusOwner); return hasMnemonic(container, keyCode) || hasMnemonicInBalloons(container, keyCode); }