src/video/cocoa/SDL_cocoawindow.m
changeset 1959 25d6537feea4
parent 1958 5fc6fb0fb605
child 1962 c92e5f3e68d9
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat Jul 29 23:00:15 2006 +0000
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Jul 30 05:18:33 2006 +0000
     1.3 @@ -148,49 +148,67 @@
     1.4  - (void)mouseDown:(NSEvent *)theEvent
     1.5  {
     1.6      int index;
     1.7 +    int button;
     1.8  
     1.9      index = _data->videodata->mouse;
    1.10 -    SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.11 +    switch ([theEvent buttonNumber]) {
    1.12 +    case 0:
    1.13 +        button = SDL_BUTTON_LEFT;
    1.14 +        break;
    1.15 +    case 1:
    1.16 +        button = SDL_BUTTON_RIGHT;
    1.17 +        break;
    1.18 +    case 2:
    1.19 +        button = SDL_BUTTON_MIDDLE;
    1.20 +        break;
    1.21 +    default:
    1.22 +        button = [theEvent buttonNumber];
    1.23 +        break;
    1.24 +    }
    1.25 +    SDL_SendMouseButton(index, SDL_PRESSED, button);
    1.26  }
    1.27  
    1.28  - (void)rightMouseDown:(NSEvent *)theEvent
    1.29  {
    1.30 -    int index;
    1.31 -
    1.32 -    index = _data->videodata->mouse;
    1.33 -    SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_RIGHT);
    1.34 +    [self mouseDown:theEvent];
    1.35  }
    1.36  
    1.37  - (void)otherMouseDown:(NSEvent *)theEvent
    1.38  {
    1.39 -    int index;
    1.40 -
    1.41 -    index = _data->videodata->mouse;
    1.42 -    SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_MIDDLE);
    1.43 +    [self mouseDown:theEvent];
    1.44  }
    1.45  
    1.46  - (void)mouseUp:(NSEvent *)theEvent
    1.47  {
    1.48      int index;
    1.49 +    int button;
    1.50  
    1.51      index = _data->videodata->mouse;
    1.52 -    SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.53 +    switch ([theEvent buttonNumber]) {
    1.54 +    case 0:
    1.55 +        button = SDL_BUTTON_LEFT;
    1.56 +        break;
    1.57 +    case 1:
    1.58 +        button = SDL_BUTTON_RIGHT;
    1.59 +        break;
    1.60 +    case 2:
    1.61 +        button = SDL_BUTTON_MIDDLE;
    1.62 +        break;
    1.63 +    default:
    1.64 +        button = [theEvent buttonNumber];
    1.65 +        break;
    1.66 +    }
    1.67 +    SDL_SendMouseButton(index, SDL_RELEASED, button);
    1.68  }
    1.69  
    1.70  - (void)rightMouseUp:(NSEvent *)theEvent
    1.71  {
    1.72 -    int index;
    1.73 -
    1.74 -    index = _data->videodata->mouse;
    1.75 -    SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_RIGHT);
    1.76 +    [self mouseUp:theEvent];
    1.77  }
    1.78  
    1.79  - (void)otherMouseUp:(NSEvent *)theEvent
    1.80  {
    1.81 -    int index;
    1.82 -
    1.83 -    index = _data->videodata->mouse;
    1.84 -    SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_MIDDLE);
    1.85 +    [self mouseUp:theEvent];
    1.86  }
    1.87  
    1.88  - (void)mouseMoved:(NSEvent *)theEvent
    1.89 @@ -238,11 +256,21 @@
    1.90  
    1.91  - (void)keyDown:(NSEvent *)theEvent
    1.92  {
    1.93 +    int index;
    1.94 +
    1.95 +    index = _data->videodata->keyboard;
    1.96  fprintf(stderr, "keyDown\n");
    1.97 +    const char *text = [[theEvent characters] UTF8String];
    1.98 +    if(text && *text) {
    1.99 +        SDL_SendKeyboardText(index, text);
   1.100 +    }
   1.101  }
   1.102  
   1.103  - (void)keyUp:(NSEvent *)theEvent
   1.104  {
   1.105 +    int index;
   1.106 +
   1.107 +    index = _data->videodata->keyboard;
   1.108  fprintf(stderr, "keyUp\n");
   1.109  }
   1.110