有菜单栏但没有 Dock 图标/切换菜单的 Cocoa 应用程序

发布于 2024-08-29 12:24:22 字数 466 浏览 3 评论 0原文

这又是“如何从使用停靠图标运行切换到不使用停靠图标运行”的问题之一。我不想要停靠图标,但当应用程序位于前面时,我确实想要一个菜单​​栏。这可能吗?

在 plist 中将 LSUIElement 设置为 1 的情况下运行应用程序将启动没有停靠图标的应用程序,不会显示在命令选项卡开关列表中,并且没有菜单

您可以从该模式切换到“正常”模式,从 10.2 开始通过 SetSystemModeUI 开启所有三个模式,从 10.6 开始通过 NSApplication setApplicationActivationPolicy 开启,但最重要的是没有办法回到之前的模式(见图)。

因此,解决这个问题的一种方法是使用 LSUIElement = 1 启动,然后在应用程序获得焦点时激活菜单栏,并在应用程序失去焦点时停用菜单栏。可惜我找不到这样做的方法。

有人可以帮忙吗?

最好的问候,

弗兰克

This is yet one more of those "how to switch from running with a dock icon to running without one" questions with a twist.. I don't want the dock icon but I do want a menu bar when the application is at the front. Is that possible?

Running an application with LSUIElement set to 1 in the plist will launch the application without a dock icon, not showing up in the command-tab switch list and without a menu.

You can switch from that mode to the "normal" mode with all three switched on via SetSystemModeUI from 10.2 onwards and via NSApplication setApplicationActivationPolicy since 10.6, but crucially there is no way back to the previous mode (go figure).

So one way around this would be to launch with LSUIElement = 1 and then activate the menu bar when the application gets the focus and deactivate it on the application losing the focus.. alas I can't find a way of doing that.

Can anybody help?

Best regards,

Frank

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流心雨 2024-09-05 12:24:22

我也在寻找解决方案,但结果很简单:
在项目文件Info.plist中需要添加键

“Application is agent (UIElement)”= YES

I too was looking for a solution, but it turned out to be quite simple:
In the project file Info.plist need to add the key

"Application is agent (UIElement)" = YES

瘫痪情歌 2024-09-05 12:24:22

不幸的是,这是不可能的。您只能以一个方向(从后台应用程序到前台应用程序)转换进程类型,而不能以其他方式转换。

Unfortunately, this is not possible. You can only transform the process type in one direction (from a background app to a foreground app) and not the other way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文