Re: notification on windowing being frontmost.
Re: notification on windowing being frontmost.
- Subject: Re: notification on windowing being frontmost.
- From: Jeremy Dronfield <email@hidden>
- Date: Fri, 4 Oct 2002 13:20:24 +0100
Your notifications aren't being sent because borderless windows can't
become key or main. (It may not be relevant, but this means your window
won't receive keyboard events either.) To make this work, you'll have to
create an NSWindow subclass for fullScreenWindow and give it this
override:
- (BOOL)canBecomeKeyWindow
{
return YES;
}
You might also want to override -canBecomeMainWindow.
-Jeremy
On Thursday, October 3, 2002, at 09:35 pm, Paul Cezanne wrote:
I need to know when a certain window has become frontmost (see below if
you care). So I pulled out google and Hillegass and started searching
and reading. Ahhh, the NotificationCenter!
So I wrote the following code:
[nc addObserver:self
selector:@selector(noLongerFrontMost:)
name:NSWindowDidBecomeKeyNotification
object:fullScreenWindow];
[nc addObserver:self
selector:@selector(noLongerFrontMost:)
name:NSWindowDidBecomeMainNotification
object: fullScreenWindow];
- (void) noLongerFrontMost:(NSNotification *) note
And alas my selector isn't called. So I took out the
"fullScreenWindow" object (see below) and put in nil. Nope, still not
called. Next I added a third observer, looking at the
NSWindowDidUpdateNotification notification. Ahh, now my selector is
called but as Keanu Reeves would say, "Woah." It is certainly called
often enough, like everytime the mouse moves. That really seems like
overkill for what I need.
So what am I doing wrong or what notification should I be longer for to
detect when a window has become frontmost?
Thanks
Paul
----------------------
nitty gritty details here.
I need to be an full screen mode for my application. I get here by
doing this:
int windowLevel;
if(CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess){
NSLog(@"CGDisplayCapture Failed");
return;
}
windowLevel = CGShieldingWindowLevel();
if(fullScreenWindow == nil){
fullScreenWindow = [[NSWindow alloc]
initWithContentRect: [[NSScreen mainScreen] frame]
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO screen:[NSScreen mainScreen]
];
[fullScreenWindow setLevel:windowLevel];
//[fullScreenWindow setIgnoresMouseEvents:true]; // -- Jaguar
only...
[fullScreenWindow setBackgroundColor:[NSColor blackColor]];
[fullScreenWindow setReleasedWhenClosed: NO];
fullScreenImageView = [[CBackgroundTargetView alloc] init];
[fullScreenWindow setContentView: fullScreenImageView];
}
[fullScreenWindow orderFront:nil];
// now bring the main window frontmost
[myMainWindow setLevel:CGShieldingWindowLevel()];
[myMainWindow makeKeyAndOrderFront:nil];
Now the problem with this approach is that when I'm running in
fullscreen mode, I really have 2 windows, my "background pattern"
window and my main window. If the user clicks on the background
window, poof, it is now in front. Yeah, I really want to call
setIgnoresMouseEvents but pre-Jaguar I can't do that.
So I had the idea to get notified when my "fullscreenwindow" became
frontmost. Other solutions are also accepted. :-)
Thanks for reading this far.
Paul
_______________________________________________
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.
_______________________________________________
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.