Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 378
Rodrigo Rivera Avatar asked Apr 09 '12 19:04

Rodrigo Rivera


1 Answers

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

like image 152
trojanfoe Avatar answered Oct 14 '22 23:10

trojanfoe