Re: Fullscreen Window
Re: Fullscreen Window
- Subject: Re: Fullscreen Window
- From: Edwin Zacharias <email@hidden>
- Date: Mon, 13 May 2002 11:58:43 -0400
On Saturday, May 11, 2002, at 04:05 PM, email@hidden wrote:
I'm trying to get the app from the Fullscreen Window tutorial on Cocoa
Dev Central working. I've created my own subclasses of NSWindow which
forces canBecomeKeyWindow to return true. I've set both the
generated-in-code mainWindow and the NIB-defined slideShowPanel to be
subclasses of it, but it still refuses to accept key input. Am I
missing something?
I have a full screen window working in an app of mine. Here's the
implementation for my NSWindow subclass:
@implementation OLFullScreenWindow
- (BOOL)canBecomeKeyWindow
{
return YES;
}
- (BOOL)canBecomeMainWindow
{
return YES;
}
@end
I'm not sure if there both necessary but its always good to be defensive
in your coding. Here's my code that turns a normal window into a full
screen window. Its pretty simple. Its in an NSWindowController
subclass. I have the _windowBuffer variable to store the original
window when I'm in full screen mode. If the _windowBuffer is nil, that
means I'm not full screen. It works by swapping the content view into
the full screen window and back again.
- (IBAction)toggleFullScreen:(id)sender
{
NSWindow *window;
if (_windowBuffer) {
[[NSNotificationCenter defaultCenter]
postNotificationName:OLImageWindowControllerWillLeaveFullScreenMode
object:self];
window = [self window];
[_windowBuffer setContentView:[window contentView]];
[self setBackgroundColor:[NSColor whiteColor]];
[self setWindow:_windowBuffer];
[window release];
window = _windowBuffer;
_windowBuffer = nil;
}
else {
[[NSNotificationCenter defaultCenter]
postNotificationName:OLImageWindowControllerWillEnterFullScreenMode
object:self];
_windowBuffer = [[self window] retain];
[_windowBuffer orderOut:nil];
window = [[OLFullScreenWindow alloc]
initWithContentRect:[[_windowBuffer screen] frame]
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered
defer:YES screen:[_windowBuffer screen]];
[window setLevel:NSMainMenuWindowLevel + 1];
[window setContentView:[_windowBuffer contentView]];
[self setBackgroundColor:[NSColor blackColor]];
[self setWindow:window];
}
[self windowWillResize:[self window] toSize:[[self window]
frame].size];
[self showWindow:nil];
}
I haven't looked at Cocoa Dev Cental's implementation, but I don't know
how it could be any simpler than this.
Just a note, my app also sets the level of all panels to above the full
screen window and sets their opacity to 80% for full screen mode. Its a
very cool effect. I can then work in full screen mode all the time.
- Edwin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.