Oscar Del Ben
Oscar Del Ben

Reputation: 4515

COCOA: Showing a window on top without giving it focus

I'm trying to emulate what growl does with an app that I have. At a certain point I want to display a window on top all other open windows, but I don't want to lose focus on the active app.

Right now the code that I have is:

[NSApp activateIgnoringOtherApps:YES];
[self makeKeyAndOrderFront:self];

This code will put the window on top, but also makes the current app the key window, which is undesired in this case.

Upvotes: 1

Views: 3058

Answers (1)

gcbrueckmann
gcbrueckmann

Reputation: 2453

Change the window level as appropriate:

[myWindow setLevel:NSFloatingWindowLevel];

For other possible window level constants check the NSWindow class reference.

Upvotes: 5

Related Questions