Mac OS X, make a window go over menu bar

♀尐吖头ヾ 提交于 2019-12-22 05:13:37

问题


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

Thanks in Advance!


回答1:


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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/6772515/mac-os-x-make-a-window-go-over-menu-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!