From 779e3bdeb63ac9533cefb9755b4c968eaa2750a4 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 28 Sep 2012 02:33:42 -0700 Subject: [PATCH] Fixed bug 1496 - SDLView not created for a Cocoa window, resulting in missing right mouse clicks When you create an nswindow it automatically gets a default view, so we'll just create an SDLView if we're creating the window. --- src/video/cocoa/SDL_cocoawindow.m | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 5dbb7125c..d50cd14d7 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -530,14 +530,6 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created /* Fill in the SDL window with the window data */ { NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; - NSView *contentView = [ nswindow contentView ]; - /* Create view if not already exists */ - if (!contentView) { - contentView = [[SDLView alloc] initWithFrame:rect]; - [nswindow setContentView: contentView]; - [contentView release]; - } - ConvertNSRect(&rect); window->x = (int)rect.origin.x; window->y = (int)rect.origin.y; @@ -627,6 +619,12 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) } nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen]; + // Create a default view for this window + rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + NSView *contentView = [[SDLView alloc] initWithFrame:rect]; + [nswindow setContentView: contentView]; + [contentView release]; + [pool release]; if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {