4

How can I make my NSWindow appear in front of every app and the menubar? I also don't want a title bar on my window. Just a fullscreen app without the dock menubar and not in apple's fullscreen mode. I can get my window above all of the other apps and dock like this:

[window setLevel:kCGPopUpMenuWindowLevel];

but it doesn't cover the mac menubar.

atomikpanda
  • 1,845
  • 5
  • 33
  • 47

3 Answers3

7

You can't move a default window higher that the menu bar, because it's constrained. You have to subclass NSWindow and override constrainFrameRect:toScreen:

- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen {
    return frameRect;
}
DrummerB
  • 39,814
  • 12
  • 105
  • 142
2

Set the window level to NSMainMenuWindowLevel + 2.

If you use NSMainMenuWindowLevel + 1 the top menu bar will still appear sometimes but is very unpredictable. NSMainMenuWindowLevel + 2 forces it to stay above the menu bar and keep focus permanently.

[window setLevel:NSMainMenuWindowLevel + 2];
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Justin
  • 2,122
  • 3
  • 27
  • 47
2

In Swift 3:

window.level = Int(CGWindowLevelForKey(.mainMenuWindow)) + 2
Sam Soffes
  • 14,831
  • 9
  • 76
  • 80