Reputation: 1886
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.
Upvotes: 4
Views: 2837
Reputation: 14935
In Swift 3:
window.level = Int(CGWindowLevelForKey(.mainMenuWindow)) + 2
Upvotes: 2
Reputation: 2142
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];
Upvotes: 2
Reputation: 40211
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;
}
Upvotes: 7