Mac OS X,使窗口越过菜单栏

发布于 2024-11-26 00:26:56 字数 45 浏览 0 评论 0原文

是否可以创建一个窗口来越过菜单栏,而不进入全屏?

提前致谢!

Is it possible to make a window to go over the menu bar, without going in fullscreen?

Thanks in Advance!

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

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

发布评论

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

评论(3

蘸点软妹酱 2024-12-03 00:26:56

是的,简单地说:(

window.level = NSMainMenuWindowLevel + 1;

参考:绘图到全屏Mac OS X 的 OpenGL 编程指南。)

sebastianmarkow 是正确的,因为这是可怕的行为对于普通文档窗口,但有几种窗口类型是正常的:光标、工具提示和特殊实用程序(如 Xscope)。

Yes, trivially:

window.level = NSMainMenuWindowLevel + 1;

(Reference: Drawing to the Full Screen, OpenGL Programming Guide for Mac OS X.)

sebastianmarkow is correct in that this is terrible behaviour for a normal document window, but there are several window types for which this is normal: cursors, tool tips, and special utilities like Xscope.

时光无声 2024-12-03 00:26:56

我喜欢 Jens Ayton 的答案,但我认为最好使用定义的常量之一,而不是选择这样的任意数字。

就我个人而言,我使用了 NSPopUpMenuWindowLevel ,如下所示:

self.window.level = NSPopUpMenuWindowLevel;

截至我发布此答案时,您可能更喜欢的其他常量包括:

  • NSNormalWindowLevel
  • NSFloatingWindowLevel
  • NSSubmenuWindowLevel
  • NSNormalWindowLevel
  • NSMainMenuWindowLevel
  • NSStatusWindowLevel
  • NSModalPaneWindowLevel
  • NSPopUpMenuWindowLevel
  • NSScreenSaverWindowLevel

这是参考(Apple 多年来倾向于改变他们组织文档的方式并打破这些链接,但是 API不会发生太大变化,这就是为什么我在上面列出了这个列表,我怀疑这个链接在 3 年内是否有效,但这些常量在未来 20 年内可能不会发生太大变化。)

https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWindow_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Window_Levels

I liked Jens Ayton's answer, but rather than pick an arbitrary number like that, I think it would be preferred that you use one of the defined constants.

Personally, I used NSPopUpMenuWindowLevel as in:

self.window.level = NSPopUpMenuWindowLevel;

Other constants that you might prefer, as of my posting this answer, include:

  • NSNormalWindowLevel
  • NSFloatingWindowLevel
  • NSSubmenuWindowLevel
  • NSNormalWindowLevel
  • NSMainMenuWindowLevel
  • NSStatusWindowLevel
  • NSModalPaneWindowLevel
  • NSPopUpMenuWindowLevel
  • NSScreenSaverWindowLevel

Here's the reference (Apple has a tendency to change how they organize their docs and break these links over the years, but the APIs don't change much, which is why I included that list above. I doubt this link will work in 3 years or so, but these constants probably won't change much in the next 20 years.)

https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWindow_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Window_Levels

秉烛思 2024-12-03 00:26:56

我不相信您可以转到菜单栏的顶部,但是当您的应用程序是最前面的应用程序时,您可以通过调用

[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationAutoHideMenuBar];

Which 来将菜单栏设置为自动隐藏,这应该让您可以使用通常用于菜单栏的空间应用。

I do not believe that you can go on top of the menu bar, but you can set the menu bar to auto-hide when your application is the frontmost application by calling

[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationAutoHideMenuBar];

Which should let you use the space normally used for the menu bar in your application.

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