diff src/macosx/native/sun/awt/AWTView.m @ 8555:d72ca6dac444

8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS" Reviewed-by: anthony, serb
author leonidr
date Tue, 22 Oct 2013 16:45:08 +0400
parents 04612a52e7bd
children bedc29a6d074
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/AWTView.m	Fri Oct 18 20:35:36 2013 +0400
+++ b/src/macosx/native/sun/awt/AWTView.m	Tue Oct 22 16:45:08 2013 +0400
@@ -272,7 +272,6 @@
  */
 
 - (void) keyDown: (NSEvent *)event {
-
     fProcessingKeystroke = YES;
     fKeyEventsNeeded = YES;
 
@@ -308,6 +307,23 @@
 
 - (BOOL) performKeyEquivalent: (NSEvent *) event {
     [self deliverJavaKeyEventHelper: event];
+
+    // Workaround for 8020209: special case for "Cmd =" and "Cmd ." 
+    // because Cocoa calls performKeyEquivalent twice for these keystrokes  
+    NSUInteger modFlags = [event modifierFlags] & 
+        (NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask);
+    if (modFlags == NSCommandKeyMask) {
+        NSString *eventChars = [event charactersIgnoringModifiers];
+        if ([eventChars length] == 1) {
+            unichar ch = [eventChars characterAtIndex:0];
+            if (ch == '=' || ch == '.') {
+                [[NSApp mainMenu] performKeyEquivalent: event];
+                return YES;
+            }
+        }
+
+    }
+
     return NO;
 }