user3932000
user3932000

Reputation: 629

How to make an NSWindow appear in front of other apps?

Sorry if this is an obvious question, but I'm new to Objective-C.

I'm making a menu bar app (doesn't show in Dock, only in menu bar), and for some reason when I open a window, it appears at the very back, behind all the other apps. I thought makeKeyAndOrderFront: would be enough, but it doesn't seem to do the trick.

So how do I make the window appear in front of other apps?

Upvotes: 2

Views: 855

Answers (1)

Brandon Horst
Brandon Horst

Reputation: 2070

You also need to activate it as well.

[NSApp activateIgnoringOtherApps:YES];
[window makeKeyAndOrderFront:nil];

If this doesn't work, is your window title-less or anything like that? If so, you need to follow Cocoa/OSX - NSTextField not responding to click for text editing to begin when titlebar is hidden

Upvotes: 4

Related Questions