简体   繁体   中英

How to know if a NSWindow is the front window?

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

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.

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

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.

(from here ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM