Rodrigo Rivera
Rodrigo Rivera

Reputation: 177

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?

Upvotes: 7

Views: 2944

Answers (1)

trojanfoe
trojanfoe

Reputation: 122458

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).

Upvotes: 5

Related Questions