From 3b5c8289e5417cb91062707595f03a2ef915c2a9 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Thu, 7 Jan 2010 13:32:21 -0600 Subject: [PATCH] fixed beeping when a non-shortcut was pressed on Mac --- platform/macosx/SDLMain.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platform/macosx/SDLMain.m b/platform/macosx/SDLMain.m index e2289e9d7..75043278d 100644 --- a/platform/macosx/SDLMain.m +++ b/platform/macosx/SDLMain.m @@ -76,6 +76,16 @@ static NSString *getApplicationName(void) event.type = SDL_QUIT; SDL_PushEvent(&event); } + +/* Hack to make Cocoa ignore keystrokes that aren't shortcuts, otherwise it beeps on every key press */ +- (void)sendEvent:(NSEvent *)theEvent { + if (NSKeyDown == [theEvent type] || NSKeyUp == [theEvent type]) { + if ([theEvent modifierFlags] & NSCommandKeyMask) + [super sendEvent: theEvent]; + } else { + [super sendEvent: theEvent]; + } +} @end /* The main class of the application, the application's delegate */