Find the topmost window under a mouse cursor

Dmitry Cherepanov dmitry.cherepanov at oracle.com
Tue Mar 27 04:24:06 PDT 2012


Anthony Petrov wrote:
> On 3/27/2012 2:19 PM, Dmitry Cherepanov wrote:
>>> 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.
>
> Is this exact behavior specified anywhere (i.e. that the cursor must 
> be updated as soon as a component appears under the mouse even if the 
> mouse holds still)? If not, I'd just state that the behavior is 
> platform-specific.

Looks like it's a part of the AWT specification:

http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#setCursor(java.awt.Cursor)

"This cursor image is displayed when the contains method for this 
component returns true for the current cursor location, and this 
Component is visible, displayable, and enabled"

Thanks,
Dmitry

>
> -- 
> best regards,
> Anthony
>
>>
>> Thanks,
>> Dmitry
>>
>>> 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