Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Hack to stop the beeping
Browse files Browse the repository at this point in the history
Fixed keyboard window focus.
  • Loading branch information
slouken committed Jul 30, 2006
1 parent bb7014b commit a1211c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/video/cocoa/SDL_cocoaevents.m
Expand Up @@ -174,7 +174,9 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
case NSKeyUp:
case NSFlagsChanged:
Cocoa_HandleKeyEvent(_this, event);
/* Fall through to pass event to NSApp */
/* Fall through to pass event to NSApp; er, nevermind... */
/* FIXME: Find a way to stop the beeping, using delegate */
break;
default:
[NSApp sendEvent:event];
break;
Expand Down
2 changes: 0 additions & 2 deletions src/video/cocoa/SDL_cocoawindow.h
Expand Up @@ -58,8 +58,6 @@ typedef struct SDL_WindowData SDL_WindowData;
-(void) rightMouseDragged:(NSEvent *) theEvent;
-(void) otherMouseDragged:(NSEvent *) theEvent;
-(void) scrollWheel:(NSEvent *) theEvent;
-(void) keyDown:(NSEvent *) theEvent;
-(void) keyUp:(NSEvent *) theEvent;
@end
/* *INDENT-ON* */

Expand Down
30 changes: 8 additions & 22 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -127,12 +127,18 @@ - (void)windowDidDeminiaturize:(NSNotification *)aNotification

- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
int index;

index = _data->videodata->keyboard;
SDL_SetKeyboardFocus(index, _data->windowID);
}

- (void)windowDidResignKey:(NSNotification *)aNotification
{
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
int index;

index = _data->videodata->keyboard;
SDL_SetKeyboardFocus(index, 0);
}

- (void)windowDidHide:(NSNotification *)aNotification
Expand Down Expand Up @@ -254,26 +260,6 @@ - (void)scrollWheel:(NSEvent *)theEvent
SDL_SendMouseWheel(index, (int)([theEvent deltaY]+0.9f));
}

- (void)keyDown:(NSEvent *)theEvent
{
int index;

index = _data->videodata->keyboard;
fprintf(stderr, "keyDown\n");
const char *text = [[theEvent characters] UTF8String];
if(text && *text) {
SDL_SendKeyboardText(index, text);
}
}

- (void)keyUp:(NSEvent *)theEvent
{
int index;

index = _data->videodata->keyboard;
fprintf(stderr, "keyUp\n");
}

@end

static int
Expand Down

0 comments on commit a1211c9

Please sign in to comment.