Re: Can NSView and NSImageView respond to Mouse Clicks?
Jack Brindle
NSView inherits from NSResponder. That gives NSView access to mouseDown, mouseUp and a whole host of other important calls.
toggle quoted messageShow quoted text
What this really means is that you can implement - (void)mouseDown:(NSEvent *)event; or v- (void) mouseUp:(NSEvent *)event; in your NSView subclass and handle mouse events the way you like, which includes generating IBAction calls to other objects that need to be notified of mouse events in your view. The event object will contains information about where the cursor was when the mouse down or up even occurred, which you can use to determine exactly where in the view the hit occurred, and even when. Note that any control embedded in the view will take precedence over the view itself, so that it gets a chance to handle the mouse down first. After all these years, I still find it really cool the way events and the responder chain works, and gives us so much power to create great user interfaces. Jack
On Sep 20, 2018, at 4:36 AM, Dave <dave@...> wrote:
|
|