notification on windowing being frontmost.
notification on windowing being frontmost.
- Subject: notification on windowing being frontmost.
- From: Paul Cezanne <email@hidden>
- Date: Thu, 3 Oct 2002 16:35:50 -0400
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.