Fix right mouse event handling in Cocoa
authorJjgod Jiang <gzjjgod@gmail.com>
Sun, 09 May 2010 12:58:58 +0800
changeset 4915834ce48a19c2
parent 4914 cc7ac6aaac5d
child 4916 3617cec7f0ee
Fix right mouse event handling in Cocoa

NSView in Cocoa has a different event handling procedure for
right mouse events (rightMouseDown: etc.)
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue Nov 23 20:29:45 2010 -0500
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun May 09 12:58:58 2010 +0800
     1.3 @@ -376,6 +376,30 @@
     1.4  }
     1.5  @end
     1.6  
     1.7 +@interface SDLView : NSView {
     1.8 +    Cocoa_WindowListener *listener;
     1.9 +}
    1.10 +@end
    1.11 +
    1.12 +@implementation SDLView
    1.13 +
    1.14 +- (id) initWithFrame: (NSRect) rect
    1.15 +            listener: (Cocoa_WindowListener *) theListener
    1.16 +{
    1.17 +    if (self = [super initWithFrame:rect]) {
    1.18 +        listener = theListener;
    1.19 +    }
    1.20 +
    1.21 +    return self;
    1.22 +}
    1.23 +
    1.24 +- (void)rightMouseDown:(NSEvent *)theEvent
    1.25 +{
    1.26 +    [listener mouseDown:theEvent];
    1.27 +}
    1.28 +
    1.29 +@end
    1.30 +
    1.31  static int
    1.32  SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
    1.33  {
    1.34 @@ -407,6 +431,11 @@
    1.35      {
    1.36          SDL_Rect bounds;
    1.37          NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.38 +        NSView *contentView = [[SDLView alloc] initWithFrame: rect
    1.39 +                                                    listener: data->listener];
    1.40 +        [nswindow setContentView: contentView];
    1.41 +        [contentView release];
    1.42 +
    1.43          ConvertNSRect(&rect);
    1.44          Cocoa_GetDisplayBounds(_this, display, &bounds);
    1.45          window->x = (int)rect.origin.x - bounds.x;