简体   繁体   中英

Menu Bar app being launched by Dock Icon (Mac OS X)

I'm working on a Menu Bar app and I've added the LSUIElement so the icon won't appear in the dock when the app is in use (And also to remove the File, Edit, View etc at the left of the menu bar).

The problem is that I want the app to be launched by the Icon and by adding the LSUIElement the only way to luanch the app is thru xcode.

I've seen that in the Mac app Caffiene it launches by the icon but it doesn't appear in the dock that it's running etc which is excatly what I want/need.

So I was wondering if you guys know how to do this.

Thank you in advance!

If you want to have a dock icon but not show the app as running in the Dock, simply create two applications:

Status Menu Application

This is the actual application that sets up the menu and contains the application's logic. It has LSUIElement set.

Launcher Application

This application has a dock icon. It contains the status menu application in its bundle. Its sole job is to launch the status menu application and then quit itself.

There is a really simple way to do this without creating a separate launcher app. Build your application, which has a status item, as an app bundle. Then, add an entry to the application's Info.plist file

Key: NSUIElement
Value: Number, 1 or Boolean True

NSUIElement tells OSX if the app should display in the Dock or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM