Re: NSWindow Level Side Effect - PopUp to Normal
Re: NSWindow Level Side Effect - PopUp to Normal
- Subject: Re: NSWindow Level Side Effect - PopUp to Normal
- From: Ken Thomases <email@hidden>
- Date: Mon, 28 Oct 2013 20:14:57 -0500
On Oct 28, 2013, at 7:32 PM, Caylan Larson wrote:
> When my app is active its windows are set to NSPopUpMenuWindowLevel. This is to capture main menu screen real estate inside of its frame (it’s a “scope”-type utility: www.labelscope.com). When I receive applicationDidResignActive, I set all windows as NSNormalWindowLevel. Problem is, the newly active app (whatever it may be) is still underneath my window(s) for one more click. The newly active application has key/main - but my app window is on top. Then, I click once more within the newly active app and my window goes behind. My window is not a ghost - because clicking anywhere on it will activate my app once again.
>
> I tried to stash the window’s level before changing it to NSPopUpMenuWindowLevel and set it back - that didn’t work.
>
> I tried to get all screen windowNumbers, remove my own app’s window numbers, and then -orderWindow:NSWindowBelow relativeTo:topForeignWindow, but that didn’t work, either.
>
> I can orderBack and my window goes way back, but this probably isn’t what the user expects.
>
> How do I hover my window above the main menu without getting this strange side-effect?
-[NSWindow setLevel:] is documented to order the window to the front of the new level. (So, this would happen even if you were raising a window from a lower level.)
"When a window enters a new level, it’s ordered in front of all its peers in that level."
Have you tried changing your window's level during -applicationWillResignActive: instead?
I believe that ordering your window behind the other window would work (after you've reduced its level), but you're not correctly identifying the target window. The window number list includes the menu bar and perhaps some other system windows. You can try to use the CGWindow API to identify the real window you want to order relative to, but you'll be making a lot of unsupported assumptions in any such heuristic.
Regards,
Ken
_______________________________________________
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