views:

228

answers:

1

I have a window that is set with NSBorderlessWindowMask, and also kCGDesktopWindowLevel. When a NSPanel is supposed to appear from say the selection of a Dock Icon menu or a Status Bar Item menu, the NSPanel will not display if the application is not the front most window.

So this program at this time only has a Status Menu Item (think how QuickSilver is implemented) and when I choose Preferences from my menu it is set to show the Preferences Panel by using Makekeyandorderfront, however unless you have just launched the application and done nothing else, when you select Preferences nothing happens.

I have found that when I choose my menu item for Sparkle's Check for Updates, that the check for update panel will appear and then my preference panel which I told to open will appear.

So it seems like makekeyandorderfront is not really bringing it to the front, perhaps.

Does anyone know how to fix this? Should I call something besides makekeyandorderfront, or maybe something in conjunction with it?

Thanks in advance

+1  A: 

Panels are designed by default to work this way. They're designed as axillary windows for your application and always disappear when the application deactivates. You will probably also run into issues with the panel becoming key... but to cure your disappearing panel issue, send this message to your panel:

[panelObject setHidesOnDeactivate:NO];

You should probably be using actual NSWindow objects here instead of NSPanel objects, but since I don't know much about how your application works, you'll have to look into that yourself. For more information on the difference between panels and windows, please review the documentation here: Window Programming Guide

Jason Coco
Is there a way to keep it with hide on deactivate but make it so when they select the menu item it brings the app to the front so they will work correctly/normally?
kdbdallas
Use a regular window and have the status menu/dock menu item's action order the window in. When you're done with it, order it out. If you want it to disappear if the user clicks somewhere else, add applicationDidResignActive to your app delegate and order it out there too.
Jason Coco
kdbdallas: Try [NSApp activateIgnoringOtherApps:NO]. If that doesn't work, try YES. If that doesn't work, try SetFrontProcessWithOptions with { 0, kCurrentProcess } and kSetFrontProcessFrontWindowOnly.
Peter Hosey