1

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!

Community
  • 1
  • 1
RaB
  • 1,545
  • 13
  • 16

1 Answers1

1

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.

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
  • thanks, I feared that it would be that way. Is there a way to package both of those objects into a single `.app` file? Otherwise it would suck if the user needed to drag 2 .apps to his applications folder or to create a `.pkg` file. – RaB Aug 23 '11 at 13:07
  • Yes, you can definitely store a helper tool inside the main app wrapper. Essentially you would build the agent app as its own target and then copy it into the `AppPackage.app/Contents/Resources` folder of your main application's bundle using a Copy Files build phase in Xcode. – Rob Keniger Aug 23 '11 at 13:14
  • Dropbox application seems to work just fine. Also system's tray menu are also shown. – JamesWebbTelescopeAlien Feb 27 '18 at 19:49