如何强制Mac窗口前景? [英] How to force Mac window to foreground?
本文介绍了如何强制Mac窗口前景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以编程方式强制将一个Mac窗口作为前窗?我有窗口句柄,并且想要确保我的窗口显示在所有其他窗口之上。我可以使用碳& Cocoa。
How can I programmatically force a mac window to be the front window? I have the window handle, and want to ensure that my window is displayed above all other windows. I can use both Carbon & Cocoa for this.
推荐答案
对于Cocoa,可以使用以下命令设置窗口级别:
For Cocoa, you can set the window level using:
[window setLevel:NSFloatingWindowLevel];
浮动窗口将显示在所有其他常规窗口之上,即使您的应用程序未处于活动状态。
A floating window will display above all other regular windows, even if your app isn't active.
如果您想让应用程式启用,您可以使用:
If you want to make your app active, you can use:
[NSApp activateIgnoringOtherApps:YES];
和
[window makeKeyAndOrderFront:nil];
这篇关于如何强制Mac窗口前景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文