Re: Best Control for Catching a Mouse Click?
Re: Best Control for Catching a Mouse Click?
- Subject: Re: Best Control for Catching a Mouse Click?
- From: Jens Alfke <email@hidden>
- Date: Mon, 07 Dec 2015 09:21:32 -0800
> On Dec 7, 2015, at 8:32 AM, Dave <email@hidden> wrote:
>
> If the User Clicks anywhere inside the base NSView, I’d like a Perform Click IBAction to be sent to the connected class (The View Controller in this case).
Make the base view a custom subclass of NSView, and override -hitTest: to return self. This will short-circuit the regular delivery of mouse events so they always go to the parent view. Then you can override -mouseDown: etc. to do whatever you want, like message the view controller.
Read the API docs of -hitTest:, or the “hit testing” section of the event handling guide, for more details.
—Jens
_______________________________________________
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