如何知道NSWindow是否是前窗? [英] How to know if a NSWindow is the front window?

查看:94
本文介绍了如何知道NSWindow是否是前窗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仅在Safari中遇到此问题,在Mac OS 10.6和10.7上的Firefox和Chrome上正常运行.

I'm having this issue in Safari only, works fine for Firefox and Chrome on Mac OS 10.6 and 10.7.

NSApplication runModalForWindow运行一个事件循环,并应将创建的窗口显示为前窗口.我有一个事件处理程序来处理插件的窗口焦点更改,当NSApplication处于非活动状态并且焦点丢失时,该事件处理程序将隐藏窗口(和其他窗口).

NSApplication runModalForWindow runs an event loop and should show the window created as the front window. I have an event handler to handle plugin's window focus change, that hides the window (and others) when the NSApplication is inactive and focus is lost.

有没有一种方法可以询问最前面的窗口或询问NSWindow是否是最前面的窗口?

Is there a way I can ask for the frontmost window or ask the NSWindow if it's the frontmost?

推荐答案

您可以使用[NSWindow isMainWindow](

You can use [NSWindow isMainWindow] (reference) to detect the main window:

最重要的文档或应用程序窗口是 用户的注意力称为主窗口.

The foremost document or application window that is the focus of the user’s attention is referred to as the main window.

(来自 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆