< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m

Print this page

        

@@ -276,10 +276,20 @@
         java_awt_event_InputEvent_CTRL_DOWN_MASK,
         java_awt_event_InputEvent_CTRL_MASK,
         java_awt_event_KeyEvent_VK_CONTROL
     },
     {
+        NSCommandKeyMask,
+        //kCGSFlagsMaskAppleLeftCommandKey,
+        //kCGSFlagsMaskAppleRightCommandKey,
+        55,
+        54,
+        java_awt_event_InputEvent_META_DOWN_MASK,
+        java_awt_event_InputEvent_META_MASK,
+        java_awt_event_KeyEvent_VK_META
+        },
+    {
         NSAlternateKeyMask,
         //kCGSFlagsMaskAppleLeftAlternateKey,
         //kCGSFlagsMaskAppleRightAlternateKey,
         58,
         0,

@@ -291,21 +301,11 @@
         NSAlternateKeyMask,
         0,
         61,
         java_awt_event_InputEvent_ALT_DOWN_MASK | java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK,
         java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK,
-        java_awt_event_KeyEvent_VK_ALT
-    },
-    {
-        NSCommandKeyMask,
-        //kCGSFlagsMaskAppleLeftCommandKey,
-        //kCGSFlagsMaskAppleRightCommandKey,
-        55,
-        54,
-        java_awt_event_InputEvent_META_DOWN_MASK,
-        java_awt_event_InputEvent_META_MASK,
-        java_awt_event_KeyEvent_VK_META
+        java_awt_event_KeyEvent_VK_ALT | java_awt_event_KeyEvent_VK_ALT_GRAPH
     },
     // NSNumericPadKeyMask
     {
         NSHelpKeyMask,
         0,

@@ -317,10 +317,11 @@
     // NSFunctionKeyMask
     {0, 0, 0, 0, 0, 0}
 };
 
 static BOOL leftAltKeyPressed;
+static BOOL altGRPressed = NO;
 
 /*
  * Almost all unicode characters just go from NS to Java with no translation.
  *  For the few exceptions, we handle it here with this small table.
  */

@@ -557,15 +558,23 @@
     jint javaModifiers = 0;
     const struct _nsKeyToJavaModifier* cur;
 
     for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
         if ((cur->nsMask & nsFlags) != 0) {
-            javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
-            if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) {
+                        
+            if (cur->nsMask == NSAlternateKeyMask) {
+                if (leftAltKeyPressed == YES) {
+                    javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
+                    if (altGRPressed == NO)
+                        break;
+                } else {
+                    leftAltKeyPressed = YES;
+                    altGRPressed = YES;
                 continue;
             }
-            break;
+            }
+            javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
         }
     }
 
     return javaModifiers;
 }
< prev index next >