简体   繁体   English

Dock Icon正在启动菜单栏应用程序(Mac OS X)

[英]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). 我正在使用菜单栏应用程序,因此我添加了LSUIElement,因此使用该应用程序时该图标不会出现在停靠栏中(并且还可以删除菜单左侧的文件,编辑,查看等酒吧)。

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. 问题是我希望该应用程序由Icon启动,并通过添加LSUIElement来启动应用程序的唯一方法是通过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. 我已经看到,在Mac应用程序Caffiene中,它是通过图标启动的,但是它并没有出现在正在运行的扩展坞中,这正是我想要的/需要的。

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: 如果您希望有一个停靠图标,但不希望该应用在Dock中运行,则只需创建两个应用:

Status Menu Application 状态菜单应用

This is the actual application that sets up the menu and contains the application's logic. 这是设置菜单并包含应用程序逻辑的实际应用程序。 It has LSUIElement set. 它具有LSUIElement设置。

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 然后,将条目添加到应用程序的Info.plist文件中

Key: NSUIElement
Value: Number, 1 or Boolean True

NSUIElement tells OSX if the app should display in the Dock or not. NSUIElement告诉OSX应用程序是否应显示在Dock中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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