4
votes

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.

3
Can you move it behind the menu bar? Or can you just not move it higher that the menubar?DrummerB
@DrummerB I can't move it behind the menubar of in front of the menubar. The menubar is like a barrier.atomikpanda

3 Answers

6
votes

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;
}
2
votes

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];
2
votes

In Swift 3:

window.level = Int(CGWindowLevelForKey(.mainMenuWindow)) + 2