Hack to stop the beeping
authorSam Lantinga <slouken@libsdl.org>
Sun, 30 Jul 2006 08:09:20 +0000
changeset 1962c92e5f3e68d9
parent 1961 f42f10fc309e
child 1963 2590b68531ef
Hack to stop the beeping
Fixed keyboard window focus.
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Sun Jul 30 06:11:52 2006 +0000
     1.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Sun Jul 30 08:09:20 2006 +0000
     1.3 @@ -174,7 +174,9 @@
     1.4          case NSKeyUp:
     1.5          case NSFlagsChanged:
     1.6              Cocoa_HandleKeyEvent(_this, event);
     1.7 -            /* Fall through to pass event to NSApp */
     1.8 +            /* Fall through to pass event to NSApp; er, nevermind... */
     1.9 +            /* FIXME: Find a way to stop the beeping, using delegate */
    1.10 +            break;
    1.11          default:
    1.12              [NSApp sendEvent:event];
    1.13              break;
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.h	Sun Jul 30 06:11:52 2006 +0000
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.h	Sun Jul 30 08:09:20 2006 +0000
     2.3 @@ -58,8 +58,6 @@
     2.4  -(void) rightMouseDragged:(NSEvent *) theEvent;
     2.5  -(void) otherMouseDragged:(NSEvent *) theEvent;
     2.6  -(void) scrollWheel:(NSEvent *) theEvent;
     2.7 --(void) keyDown:(NSEvent *) theEvent;
     2.8 --(void) keyUp:(NSEvent *) theEvent;
     2.9  @end
    2.10  /* *INDENT-ON* */
    2.11  
     3.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun Jul 30 06:11:52 2006 +0000
     3.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Jul 30 08:09:20 2006 +0000
     3.3 @@ -127,12 +127,18 @@
     3.4  
     3.5  - (void)windowDidBecomeKey:(NSNotification *)aNotification
     3.6  {
     3.7 -    SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
     3.8 +    int index;
     3.9 +
    3.10 +    index = _data->videodata->keyboard;
    3.11 +    SDL_SetKeyboardFocus(index, _data->windowID);
    3.12  }
    3.13  
    3.14  - (void)windowDidResignKey:(NSNotification *)aNotification
    3.15  {
    3.16 -    SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
    3.17 +    int index;
    3.18 +
    3.19 +    index = _data->videodata->keyboard;
    3.20 +    SDL_SetKeyboardFocus(index, 0);
    3.21  }
    3.22  
    3.23  - (void)windowDidHide:(NSNotification *)aNotification
    3.24 @@ -254,26 +260,6 @@
    3.25      SDL_SendMouseWheel(index, (int)([theEvent deltaY]+0.9f));
    3.26  }
    3.27  
    3.28 -- (void)keyDown:(NSEvent *)theEvent
    3.29 -{
    3.30 -    int index;
    3.31 -
    3.32 -    index = _data->videodata->keyboard;
    3.33 -fprintf(stderr, "keyDown\n");
    3.34 -    const char *text = [[theEvent characters] UTF8String];
    3.35 -    if(text && *text) {
    3.36 -        SDL_SendKeyboardText(index, text);
    3.37 -    }
    3.38 -}
    3.39 -
    3.40 -- (void)keyUp:(NSEvent *)theEvent
    3.41 -{
    3.42 -    int index;
    3.43 -
    3.44 -    index = _data->videodata->keyboard;
    3.45 -fprintf(stderr, "keyUp\n");
    3.46 -}
    3.47 -
    3.48  @end
    3.49  
    3.50  static int