Re: Cocoa window messages in app being ported from Carbon
Re: Cocoa window messages in app being ported from Carbon
- Subject: Re: Cocoa window messages in app being ported from Carbon
- From: Rob Petrovec via Cocoa-dev <email@hidden>
- Date: Sat, 10 Aug 2019 16:04:13 -0600
> On Aug 10, 2019, at 3:38 PM, Uli Kusterer <email@hidden>
> wrote:
>
>> On 10. Aug 2019, at 19:03, Rob Petrovec via Cocoa-dev
>> <email@hidden <mailto:email@hidden>> wrote:
>>
>>> On Aug 10, 2019, at 12:24 AM, Kurt Bigler via Cocoa-dev
>>> <email@hidden <mailto:email@hidden>> 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 (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