mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-135540 process extended key code
This commit is contained in:
+9
-2
@@ -53,6 +53,7 @@ import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.openapi.wm.impl.IdeGlassPaneEx;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.ComponentWithMnemonics;
|
||||
import com.intellij.ui.KeyStrokeAdapter;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.components.JBOptionButton;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
@@ -339,7 +340,10 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
return false;
|
||||
}
|
||||
|
||||
KeyStroke originalKeyStroke=KeyStroke.getKeyStrokeForEvent(e);
|
||||
KeyStroke originalKeyStroke = KeyStrokeAdapter.getDefaultKeyStroke(e);
|
||||
if (originalKeyStroke == null) {
|
||||
return false;
|
||||
}
|
||||
KeyStroke keyStroke=getKeyStrokeWithoutMouseModifiers(originalKeyStroke);
|
||||
|
||||
updateCurrentContext(myContext.getFoundComponent(), new KeyboardShortcut(myFirstKeyStroke, keyStroke), myContext.isModalContext());
|
||||
@@ -406,7 +410,10 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
KeyStroke originalKeyStroke=KeyStroke.getKeyStrokeForEvent(e);
|
||||
KeyStroke originalKeyStroke = KeyStrokeAdapter.getDefaultKeyStroke(e);
|
||||
if (originalKeyStroke == null) {
|
||||
return false;
|
||||
}
|
||||
KeyStroke keyStroke=getKeyStrokeWithoutMouseModifiers(originalKeyStroke);
|
||||
|
||||
if (myKeyGestureProcessor.processInitState()) {
|
||||
|
||||
+1
-9
@@ -22,7 +22,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.keymap.impl.ui;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.KeyStrokeAdapter;
|
||||
|
||||
@@ -49,14 +48,7 @@ public class ShortcutTextField extends JTextField {
|
||||
){
|
||||
return;
|
||||
}
|
||||
// On Windows and Mac it is preferable to use normal key code here
|
||||
// see java.awt.event.KeyEvent.getExtendedKeyCode
|
||||
boolean extendedKeyCodeFirst = !SystemInfo.isWindows && !SystemInfo.isMac;
|
||||
KeyStroke stroke = KeyStrokeAdapter.getKeyStroke(e, extendedKeyCodeFirst);
|
||||
if (stroke == null) {
|
||||
stroke = KeyStrokeAdapter.getKeyStroke(e, !extendedKeyCodeFirst);
|
||||
}
|
||||
setKeyStroke(stroke);
|
||||
setKeyStroke(KeyStrokeAdapter.getDefaultKeyStroke(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -73,6 +74,18 @@ public class KeyStrokeAdapter implements KeyListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event the specified key event to process
|
||||
* @return a key stroke or {@code null} if it is not applicable
|
||||
* @see KeyStroke#getKeyStrokeForEvent(KeyEvent)
|
||||
*/
|
||||
public static KeyStroke getDefaultKeyStroke(KeyEvent event) {
|
||||
// On Windows and Mac it is preferable to use normal key code here
|
||||
boolean extendedKeyCodeFirst = !SystemInfo.isWindows && !SystemInfo.isMac;
|
||||
KeyStroke stroke = getKeyStroke(event, extendedKeyCodeFirst);
|
||||
return stroke != null ? stroke : getKeyStroke(event, !extendedKeyCodeFirst);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event the specified key event to process
|
||||
* @param extended {@code true} if extended key code should be used
|
||||
|
||||
Reference in New Issue
Block a user