Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X, make a window go over menu bar

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

Thanks in Advance!

like image 652
mxg Avatar asked Jul 21 '11 07:07

mxg


2 Answers

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.

like image 92
Jens Ayton Avatar answered Sep 24 '22 11:09

Jens Ayton


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

like image 38
ArtOfWarfare Avatar answered Sep 20 '22 11:09

ArtOfWarfare