Re: Mouse cursors and overlapping sibling NSViews
Re: Mouse cursors and overlapping sibling NSViews
- Subject: Re: Mouse cursors and overlapping sibling NSViews
- From: Sean McBride <email@hidden>
- Date: Wed, 23 Apr 2014 10:39:02 -0400
- Organization: Rogue Research Inc.
On Wed, 23 Apr 2014 08:58:49 -0500, Ken Thomases said:
>> I have a custom NSView that needs to change its cursor depending on
>mouse position and internal state. The sibling views (which all draw on
>top of my view, thus appearing sorta like subviews) are simple standard
>Cocoa controls (ex: push buttons, popup menus). Since those siblings
>views are always 'on top', I want them to decide the mouse cursor if the
>cursor is above them, but Cocoa still calls my mouseMoved: method, which
>I guess is not unreasonable since the cursor is in fact above several
>views at the same time.
>>
>> I haven't been able to find any docs about how cursor handling works
>with overlapping views, anyone know?
>
>I don't know of any docs. I suspect the superview iterates through its
>subviews in the order they appear in the array returned by the -subviews
>method, calling -hitTest: on each until one returns a hit (i.e. non-
>nil).
Probably you're right, it certainly seems to use that order when drawing.
Is hitTest: used for cursors as well as clicks? I put a breakpoint to test the theory, and indeed I see in a backtrace [NSWindow(NSCarbonExtensions) _setCursorForMouseLocation:]
>So, you might try overriding -hitTest: for the superview and
>implementing the logic you prefer.
How would I distinguish being in hitTest: because of a mouse click vs because of a cursor set? Check the current event type?
Cheers,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden