通过 Dock Icon (Mac OS X) 启动菜单栏应用程序
我正在开发一个菜单栏应用程序,并且添加了 LSUIElement,以便在使用该应用程序时图标不会出现在扩展坞中(并且还删除菜单左侧的文件、编辑、查看等)酒吧)。
问题是我希望应用程序由 Icon 启动,并且通过添加 LSUIElement 来启动应用程序的唯一方法是通过 xcode。
我已经看到,在 Mac 应用程序 Caffiene 中,它通过图标启动,但它没有出现在它正在运行的扩展坞中,这正是我想要/需要的。
所以我想知道你们是否知道如何做到这一点。
先感谢您!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想要一个 Dock 图标但不将应用程序显示为在 Dock 中运行,只需创建两个应用程序:
状态菜单应用程序
这是设置菜单并包含应用程序逻辑的实际应用程序。它已设置
LSUIElement
。启动器应用程序
此应用程序有一个停靠图标。它的捆绑包中包含状态菜单应用程序。它的唯一工作是启动状态菜单应用程序,然后自行退出。
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.
有一种非常简单的方法可以做到这一点,无需创建单独的启动器应用程序。将具有状态项的应用程序构建为应用程序包。然后,向应用程序的 Info.plist 文件添加一个条目,
NSUIElement 告诉 OSX 应用程序是否应该显示在 Dock 中。
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
NSUIElement tells OSX if the app should display in the Dock or not.