开发者

Mac OS X, make a window go over menu bar

Is it possible to make a window to go over the menu bar, withou开发者_运维百科t going in fullscreen?

Thanks in Advance!


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜