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.
Change the window level as appropriate:
[myWindow setLevel:NSFloatingWindowLevel];
For other possible window level constants check the NSWindow class reference.
精彩评论