开发者

COCOA: Showing a window on top without giving it focus

开发者 https://www.devze.com 2023-03-26 17:39 出处:网络
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 activ

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消