NSWindow contentView buffer

  • I'm playing with the snippet found at this post:

    http://www.cocoabuilder.com/archive/message/cocoa/2002/5/13/62007

    Why doesn't retaining the contentView work for my custom view, but is
    okay for all the others? Also, if I don't retain my view when I
    setContentView: the app crashes after the 1st run.

    My aim is to toggle fullscreen, but rather than all content appearing
    in full screen, restrict it to my custom view.

    Any ideas?

    - (IBAction)toggleFullScreen:(id)sender
    {
    if (_windowBuffer) {
      [[NSNotificationCenter defaultCenter]
    postNotificationName:SCIWindowControllerWillLeaveFullScreenMode
    object:self];
      window = [self window];
      [_windowBuffer setContentView:_contentViewBuffer];
      [self setWindow:_windowBuffer];
      [window release];
      window = _windowBuffer;
      [_contentViewBuffer release];
      _windowBuffer = nil;
    }
    else {
      [[NSNotificationCenter defaultCenter]
    postNotificationName:SCIWindowControllerWillEnterFullScreenMode
    object:self];

      _windowBuffer = [[self window] retain];
      _contentViewBuffer = [[[self window] contentView] retain];

      [_windowBuffer orderOut:nil];
      window = [[SCIFullScreenWindow alloc]
    initWithContentRect:[[_windowBuffer screen] frame]
                  styleMask:NSBorderlessWindowMask
                                                             backing:NSBackingStoreBuffered
                  defer:YES
                                                             screen:[_windowBuffer screen]];

      [window setLevel:NSMainMenuWindowLevel + 1];
      [window setContentView:view]; //IBOutlet to my custom view
      [self setWindow:window];
    }

    [self windowWillResize:[self window] toSize:[[self window] frame].size];
    [self showWindow:nil];
    }
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today