开发者

NSStatusItem menu does not show up in lion full screen app

开发者 https://www.devze.com 2023-03-30 15:01 出处:网络
I have a foreground application that shows a NSStatusItem along with a menu (via NSStatusItem setMenu:(NSMenu *)menu). However, this menu does not display when I am looking at another app in fullscree

I have a foreground application that shows a NSStatusItem along with a menu (via NSStatusItem setMenu:(NSMenu *)menu). However, this menu does not display when I am looking at another app in fullscreen mode (say Safari) in Lion.

I know that I can make it work by setting NSBGOnly to true in the Info.plist file (or NSUIElement), but both methods will make my app icon disappear from the task switcher as well as hide the main menu once I manage to focus my app.

Finally, I have tried setting NSUIElement to true and do the following in my app upon startup (see also How to hide the Dock icon):

ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);

This made the menubar appear again as well as the dock icon but the original problem (status item menu does not show up in another fullscreen app) is visible again. Whatever I try, I can't win.

Any suggestions would be highly appreciated开发者_如何转开发!


Unfortunately I think this is expected behaviour. Your app is considered a foreground app, so all its UI is disabled while another app is in full screen. You should file a bug if you feel that status items in foreground apps should still be available to other apps in full screen mode.

Probably the best solution would be to split your app into two parts, an agent app which has LSUIElement set to true, which creates and manages the status item and its menu, and your main foreground app which does most of the work and which launches and manages the agent app.

There are a variety of inter-process communication methods that you can use to get the two apps talking to each other, such as Distributed Objects or Apple Events.

0

精彩评论

暂无评论...
验证码 换一张
取 消