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

Commit

Permalink
Fix right mouse event handling in Cocoa
Browse files Browse the repository at this point in the history
NSView in Cocoa has a different event handling procedure for
right mouse events (rightMouseDown: etc.)
  • Loading branch information
jjgod committed May 9, 2010
1 parent 315fcfc commit 6da62ad
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -376,6 +376,30 @@ - (BOOL)canBecomeMainWindow
}
@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)
{
Expand Down Expand Up @@ -407,6 +431,11 @@ - (BOOL)canBecomeMainWindow
{
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;
Expand Down

0 comments on commit 6da62ad

Please sign in to comment.