• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Borderless window and focus
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Borderless window and focus


  • Subject: Re: Borderless window and focus
  • From: Ricky Sharp <email@hidden>
  • Date: Tue, 21 Jul 2009 17:06:21 -0500


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:email@hidden Instant Interactive(tm) http://www.instantinteractive.com



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Borderless window and focus (From: ss2 cire <email@hidden>)

  • Prev by Date: Borderless window and focus
  • Next by Date: List FAQ and Cocoa learning resources
  • Previous by thread: Borderless window and focus
  • Next by thread: List FAQ and Cocoa learning resources
  • Index(es):
    • Date
    • Thread