IDEA-111466 Mac OS X keyboard shortcuts with alt don't work under Oracle Java 7

This commit is contained in:
Denis Fokin
2014-07-18 19:44:07 +04:00
parent 55a8bd43b0
commit c6ff466602
@@ -314,6 +314,30 @@ public final class IdeKeyEventDispatcher implements Disposable {
}
}
private static KeyStroke getKeyStrokeWithoutCtrlModifier(KeyStroke originalKeyStroke){
int modifier=originalKeyStroke.getModifiers()&~InputEvent.CTRL_MASK&~InputEvent.CTRL_DOWN_MASK;
try {
Method[] methods=AWTKeyStroke.class.getDeclaredMethods();
Method getCachedStrokeMethod=null;
for (Method method : methods) {
if (GET_CACHED_STROKE_METHOD_NAME.equals(method.getName())) {
getCachedStrokeMethod = method;
getCachedStrokeMethod.setAccessible(true);
break;
}
}
if(getCachedStrokeMethod==null){
throw new IllegalStateException("not found method with name getCachedStrokeMethod");
}
Object[] getCachedStrokeMethodArgs=
{originalKeyStroke.getKeyChar(), originalKeyStroke.getKeyCode(), modifier, originalKeyStroke.isOnKeyRelease()};
return (KeyStroke)getCachedStrokeMethod.invoke(originalKeyStroke, getCachedStrokeMethodArgs);
}
catch(Exception exc){
throw new IllegalStateException(exc.getMessage());
}
}
private boolean inSecondStrokeInProgressState() {
KeyEvent e = myContext.getInputEvent();
@@ -395,6 +419,9 @@ public final class IdeKeyEventDispatcher implements Disposable {
KeyStroke originalKeyStroke=KeyStroke.getKeyStrokeForEvent(e);
KeyStroke keyStroke=getKeyStrokeWithoutMouseModifiers(originalKeyStroke);
if (SystemInfo.isMac && SystemInfo.isOracleJvm && (keyStroke.getModifiers() & InputEvent.ALT_MASK) == InputEvent.ALT_MASK) {
keyStroke = getKeyStrokeWithoutCtrlModifier(keyStroke);
}
if (myKeyGestureProcessor.processInitState()) {
return true;