Cocoa: suppress unwanted beep when pressing Cmd + key on 10.4
authorDamien Plisson <damien.plisson@yahoo.fr>
Wed, 2 Dec 2009 15:02:29 +0000 (15:02 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Wed, 2 Dec 2009 15:02:29 +0000 (15:02 +0000)
intern/ghost/intern/GHOST_WindowCocoa.mm

index b1b23963b3d72594b0e3fc11bf1d56b8adbce7a4..4058d721bdbfc2e11fefe7ff11a5482fd5e8f334 100644 (file)
@@ -230,6 +230,28 @@ extern "C" {
 - (void)keyDown:(NSEvent *)theEvent
 {}
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
+//Cmd+key are handled differently before 10.5
+- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
+{
+       NSString *chars = [theEvent charactersIgnoringModifiers];
+       
+       if ([chars length] <1) 
+               return NO;
+       
+       //Let cocoa handle menu shortcuts
+       switch ([chars characterAtIndex:0]) {
+               case 'q':
+               case 'w':
+               case 'h':
+               case 'm':
+                       return NO;
+               default:
+                       return YES;
+       }
+}
+#endif
+
 - (BOOL)isOpaque
 {
     return YES;