# HG changeset patch # User Jjgod Jiang # Date 1273381138 -28800 # Node ID 834ce48a19c2d4be9e39db7ee6a752db7bf559b3 # Parent cc7ac6aaac5dc963a4e3bd7db21280dde18d17a7 Fix right mouse event handling in Cocoa NSView in Cocoa has a different event handling procedure for right mouse events (rightMouseDown: etc.) diff -r cc7ac6aaac5d -r 834ce48a19c2 src/video/cocoa/SDL_cocoawindow.m --- a/src/video/cocoa/SDL_cocoawindow.m Tue Nov 23 20:29:45 2010 -0500 +++ b/src/video/cocoa/SDL_cocoawindow.m Sun May 09 12:58:58 2010 +0800 @@ -376,6 +376,30 @@ } @end +@interface SDLView : NSView { + Cocoa_WindowListener *listener; +} +@end + +@implementation SDLView + +- (id) initWithFrame: (NSRect) rect + listener: (Cocoa_WindowListener *) theListener +{ + if (self = [super initWithFrame:rect]) { + listener = theListener; + } + + return self; +} + +- (void)rightMouseDown:(NSEvent *)theEvent +{ + [listener mouseDown:theEvent]; +} + +@end + static int SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created) { @@ -407,6 +431,11 @@ { SDL_Rect bounds; NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + NSView *contentView = [[SDLView alloc] initWithFrame: rect + listener: data->listener]; + [nswindow setContentView: contentView]; + [contentView release]; + ConvertNSRect(&rect); Cocoa_GetDisplayBounds(_this, display, &bounds); window->x = (int)rect.origin.x - bounds.x;