Re: Mouse cursors and overlapping sibling NSViews
Re: Mouse cursors and overlapping sibling NSViews
- Subject: Re: Mouse cursors and overlapping sibling NSViews
- From: Ken Thomases <email@hidden>
- Date: Wed, 23 Apr 2014 18:58:46 -0500
On Apr 23, 2014, at 9:39 AM, Sean McBride wrote:
> 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:]
-hitTest: should be used for anything which needs to determine which view a mouse location is associated with.
>> 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?
Why do you want to distinguish that? If the cursor is appropriate for a given view, that's a *strong* indication to the user that a click will act on that view. So, the view controlling the cursor at a given point should also be the view that receives the click at that point.
Another thing you can try, depending on what's actually in the sibling views, is to have the superview take over all mouse events. Have its -hitTest: return itself or nil, never a subview (even indirectly by invoking -hitTest: on its subviews or super). Then it controls both the cursor and the response to clicks.
Regards,
Ken
_______________________________________________
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