On Jul 21, 2009, at 4:56 PM, ss2 cire wrote:

I have the following code to initialize a borderless window for "fullscreen"

- (void)initFullScreenWindow
{
        NSScreen *theScreen = [[NSScreen screens] objectAtIndex:0];
NSRect screenRect = NSMakeRect(0, 0, [theScreen frame].size.width, [theScreen frame].size.height);

        fullScreenWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                                                                
   styleMask:NSBorderlessWindowMask
                                                                                
     backing:NSBackingStoreBuffered
                                                                                
           defer:YES];
}

I would recommend creating a subclass of NSWindow. In its designated initializer, call initWithContentRect:::: as above. You may also want to set the following properties:

                [self setMovableByWindowBackground:NO];
                [self setHasShadow:NO];
                [self useOptimizedDrawing:YES];


Also provide these in your subclass:

- (BOOL)canBecomeKeyWindow
{
        return YES;
}

- (BOOL)canBecomeMainWindow
{
        return YES;
}


In your code that creates the instance of this custom window, issue a makeKeyAndOrderFront on that instance. Things should then work a-ok.


then i have this code to show/hide the menubar and do my "fullscreen" window magic:

- (IBAction)showHideMenubar:(id)sender
{
        if(fullScreenWindow == nil) {
                [self initFullScreenWindow];
        }
        if([NSMenu menuBarVisible]) {
                [NSMenu setMenuBarVisible:NO];
                [RSCWindow orderOut:self];
                [fullScreenWindow setContentView:rsWebView];
                [fullScreenWindow makeKeyAndOrderFront:self];
        } else {
                [fullScreenWindow orderOut:self];
                [RSCWindow setContentView:rsWebView];
                [RSCWindow makeKeyAndOrderFront:self];
                [rsWebView setFrame:rsWebViewNormalWindowFrame];
                [NSMenu setMenuBarVisible:YES];
        }
}

You can also use the SetSystemUIMode API to control the visibility of menu bar and/or dock.


___________________________________________________________
Ricky A. Sharp         mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to