开发者

Defocus application when last window closes

开发者 https://www.devze.com 2023-03-07 04:14 出处:网络
Not sure if t开发者_开发百科his is the right word to use but i need to \"Defocus\" my application when the user closes the last window (Order it to the background). Preferably giving the focus to the

Not sure if t开发者_开发百科his is the right word to use but i need to "Defocus" my application when the user closes the last window (Order it to the background). Preferably giving the focus to the application that was running in the foreground before my application became foreground. How do I go about achieving this?

Thanks,

Robert


Try using -[NSApplication deactivate].

[[NSApplication sharedApplication] deactivate];

If that doesn't do what you want (which is entirely likely), try this:

[[NSApplication sharedApplication] hide:nil];
[[NSApplication sharedApplication] unhideWithoutActivation];

Note that this is not necessarily something that you should be doing. If I'm picturing what your application is doing correctly, it seems that you should consider making it an agent application.

0

精彩评论

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