> On Aug 10, 2019, at 3:38 PM, Uli Kusterer <witness.of.teacht...@gmx.net> > wrote: > >> On 10. Aug 2019, at 19:03, Rob Petrovec via Cocoa-dev >> <cocoa-dev@lists.apple.com <mailto:cocoa-dev@lists.apple.com>> wrote: >> >>> On Aug 10, 2019, at 12:24 AM, Kurt Bigler via Cocoa-dev >>> <cocoa-dev@lists.apple.com <mailto:cocoa-dev@lists.apple.com>> wrote: >>> >>> The NSView subclasses involved are receiving drawRect: messages but are not >>> receiving mouseDown:. >> You need to implement NSView -hitTest: to get mouseDown events. >> >> —Rob > > > No, the default implementation does all you need and is perfectly fine. I’ll repeat myself, the OP is not getting mouseDown on his NSView subclass. So it isn’t perfectly fine in this case. If he wants mouseDown events in his NSView subclass he needs to override hitTest to return self, or whatever subview he wants to get mouseDown. There is no avoiding it.
The default implementation of NSView hitTest just loops through it’s visible subviews and calls hitTest on each one that the passed in point is inside. It is obviously recursive. If any of the subviews return a valid view from their implementations of -hitTest: then that valid view is returned up the call stack. Whatever view is returned from -hitTest: at the top of the call stack will get first crack at the mouseDown event. Since NSViews don’t have subviews by default, let alone one that returns a valid view from hitTest, then the default implementation of an NSView -hitTest will return nil. Semantics, I know... Either way, instead of going back & forth on this, why don’t you try implementing an NSView subclass without hitTest returning self and see if that view gets -mouseDown:. Then override -hitTest in the view to return self and see that the view does get -mouseDown. Then you will see that I am correct. Thanks. —Rob _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com