Mac OS X, go to the menu through the menu bar

Can I make a window to go through the menu bar without entering full-screen mode?

Thanks at Advance!

+5
source share
3 answers

Yes, it is trivial:

window.level = NSMainMenuWindowLevel + 1; 

(Link: Drawing in full screen mode , OpenGL Programming Guide for Mac OS X.)

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

+13
source

I liked Jens Ayton's answer, but instead of choosing that amount, I think it would be preferable for you to use one of the specific constants.

Personally, I used NSPopUpMenuWindowLevel as in:

 self.window.level = NSPopUpMenuWindowLevel; 

Other constants you might prefer in my post of this answer include:

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

Here's a link (Apple tends to change the way they organize their documents and break these links over the years, but the APIs don't change much, so I included this list above. I doubt this link will work after 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
source

I do not believe that you can go on top of the menu bar, but you can set the menu bar to automatically hide when your application is the very first application, calling

 [[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationAutoHideMenuBar]; 

Which should allow you to use the space commonly used for the menu bar in your application.

+2
source

Source: https://habr.com/ru/post/980368/


All Articles