diff src/video/cocoa/SDL_cocoaevents.m @ 1959:25d6537feea4

Implemented Cocoa key event handling.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 30 Jul 2006 05:18:33 +0000
parents 05e88d266921
children c92e5f3e68d9
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoaevents.m	Sat Jul 29 23:00:15 2006 +0000
+++ b/src/video/cocoa/SDL_cocoaevents.m	Sun Jul 30 05:18:33 2006 +0000
@@ -89,9 +89,9 @@
     [appleMenu addItem:[NSMenuItem separatorItem]];
 
     title = [@"Hide " stringByAppendingString:appName];
-    [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
+    [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@/*"h"*/""];
 
-    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
+    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@/*"h"*/""];
     [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
 
     [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
@@ -99,7 +99,7 @@
     [appleMenu addItem:[NSMenuItem separatorItem]];
 
     title = [@"Quit " stringByAppendingString:appName];
-    [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
+    [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@/*"q"*/""];
     
     /* Put menu into the menubar */
     menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
@@ -116,7 +116,7 @@
     windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
     
     /* "Minimize" item */
-    menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
+    menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@/*"m"*/""];
     [windowMenu addItem:menuItem];
     [menuItem release];
     
@@ -169,7 +169,16 @@
         if ( event == nil ) {
             break;
         }
-        [NSApp sendEvent:event];
+        switch ([event type]) {
+        case NSKeyDown:
+        case NSKeyUp:
+        case NSFlagsChanged:
+            Cocoa_HandleKeyEvent(_this, event);
+            /* Fall through to pass event to NSApp */
+        default:
+            [NSApp sendEvent:event];
+            break;
+        }
     }
     [pool release];
 }