Fixed bug 1496 - SDLView not created for a Cocoa window, resulting in missing right mouse clicks
authorSam Lantinga <slouken@libsdl.org>
Fri, 28 Sep 2012 02:33:42 -0700
changeset 648931449ea8f934
parent 6488 7b2f712bdf1a
child 6490 d2d8576aa3a0
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
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Fri Sep 28 02:15:44 2012 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Sep 28 02:33:42 2012 -0700
     1.3 @@ -530,14 +530,6 @@
     1.4      /* Fill in the SDL window with the window data */
     1.5      {
     1.6          NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
     1.7 -        NSView *contentView = [ nswindow contentView ];
     1.8 -        /* Create view if not already exists */
     1.9 -        if (!contentView) {
    1.10 -            contentView = [[SDLView alloc] initWithFrame:rect];
    1.11 -            [nswindow setContentView: contentView];
    1.12 -            [contentView release];
    1.13 -        }
    1.14 -
    1.15          ConvertNSRect(&rect);
    1.16          window->x = (int)rect.origin.x;
    1.17          window->y = (int)rect.origin.y;
    1.18 @@ -627,6 +619,12 @@
    1.19      }
    1.20      nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen];
    1.21  
    1.22 +    // Create a default view for this window
    1.23 +    rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.24 +    NSView *contentView = [[SDLView alloc] initWithFrame:rect];
    1.25 +    [nswindow setContentView: contentView];
    1.26 +    [contentView release];
    1.27 +
    1.28      [pool release];
    1.29  
    1.30      if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {