Find the topmost window under a mouse cursor

Dmitry Cherepanov dmitry.cherepanov at
Tue Mar 27 03:19:40 PDT 2012

Anthony Petrov wrote:
> Hi Alexander,
> I suggest to track the MouseIsOver state with a boolean flag per 
> window, and send a synthetic Entered event upon receiving any other 
> mouse event (Moved, Clicked, etc.)

We should probably synthesize such mouse enter/exit events upon changing 
window's bounds. Synthesizing the mouse enter/exit event upon receiving 
any other mouse event wouldn't changes the mouse cursor until the user 
performs any mouse action.


> if the flag indicates we haven't yet sent an Entered event for this 
> window. The flag should be set/reset in the Entered/Exited mouse 
> handlers.
> We use this approach in FX and everyone seems to be happy about that.
> -- 
> best regards,
> Anthony
> On 3/27/2012 12:08 PM, Alexander Scherbatiy wrote:
>> Hello,
>> Does the Mac OS X contains a method that allows to find the topmost 
>> window under a mouse cursor?
>> There is the issue when a window is created under a mouse cursor or 
>> it is moved under a mouse cursor the system does not generate the 
>> NSMouseEntered event.
>> It is possible to synthetically generate the MouseEntered event for  
>> window creation and moving in Java because we need that a window 
>> behavior on Mac OS X was the same as on others platforms.
>> But it is necessary to have a way to know is this window the topmost 
>> under a mouse cursor.
>> Thanks,
>> Alexandr.

More information about the macosx-port-dev mailing list