mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-198957: Regression: Mnemonics broken on almost all of the Window submenu items
This commit is contained in:
+15
-9
@@ -96,6 +96,7 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
* KEY_TYPED event because they are not valid.
|
||||
*/
|
||||
private boolean myPressedWasProcessed;
|
||||
private boolean myIgnoreNextKeyTypedEvent;
|
||||
private KeyState myState = KeyState.STATE_INIT;
|
||||
|
||||
private final PresentationFactory myPresentationFactory = new PresentationFactory();
|
||||
@@ -141,6 +142,11 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (myIgnoreNextKeyTypedEvent) {
|
||||
if (KeyEvent.KEY_TYPED == e.getID()) return true;
|
||||
myIgnoreNextKeyTypedEvent = false;
|
||||
}
|
||||
|
||||
if (isSpeedSearchEditing(e)) {
|
||||
return false;
|
||||
}
|
||||
@@ -446,15 +452,10 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
boolean keyTyped = e.getID() == KeyEvent.KEY_TYPED;
|
||||
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)) {
|
||||
setPressedWasProcessed(true);
|
||||
setState(KeyState.STATE_PROCESSED);
|
||||
if (SystemInfo.isMac && InputEvent.ALT_DOWN_MASK == e.getModifiersEx() && Registry.is("ide.mac.alt.mnemonic.without.ctrl")) {
|
||||
// the myIgnoreNextKeyTypedEvent changes event processing to support Alt-based mnemonics on Mac only
|
||||
if (KeyEvent.KEY_TYPED == e.getID() && !IdeEventQueue.getInstance().isInputMethodEnabled() || hasMnemonicInWindow(focusOwner, e)) {
|
||||
myIgnoreNextKeyTypedEvent = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -537,6 +538,11 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
return secondKeyStrokes;
|
||||
}
|
||||
|
||||
private static boolean hasMnemonicInWindow(Component focusOwner, KeyEvent event) {
|
||||
return KeyEvent.KEY_TYPED == event.getID() && hasMnemonicInWindow(focusOwner, event.getKeyChar()) ||
|
||||
KeyEvent.KEY_PRESSED == event.getID() && hasMnemonicInWindow(focusOwner, event.getKeyCode());
|
||||
}
|
||||
|
||||
private static boolean hasMnemonicInWindow(Component focusOwner, int keyCode) {
|
||||
if (keyCode == KeyEvent.VK_ALT || keyCode == 0) return false; // Optimization
|
||||
final Container container = focusOwner == null ? null : UIUtil.getWindow(focusOwner);
|
||||
|
||||
Reference in New Issue
Block a user