Re: Getting hitTest of Subview
Re: Getting hitTest of Subview
- Subject: Re: Getting hitTest of Subview
- From: j o a r <email@hidden>
- Date: Sun, 3 Nov 2002 00:53:59 +0100
On Saturday, Nov 2, 2002, at 23:42 Europe/Stockholm, Craig Bakalian
wrote:
I was doing the hitTest in the wrong subclass. The hitTest needed to
be in the superview so the mouseDown would not create an instance on
top of another instance.
Hmm... Yes, I guess if that is something you need to check you might
want to implement hitTest: in the superview and have it return "self"
if the mouse down is not inside the frame of any existing subview. It's
hard to give you any good advice without knowing more about your
application though.
I think I need to set the acceptsFirstResponder to get the mouseDown
before the superview does, because this is a subview?
No, that's not really what first responder is all about. I don't think
that you can ever get the mouse event to the subview before the
superview, IIRC it travels from the window and down the view hierarchy.
If no superview in the view hierarchy claims the event before it
reaches a particular subview then that subview is free to act on it. If
a view has subviews that it needs to shield from mouse events for some
reason it needs to implement hitTest:. If it returns "self" it's
subviews will not get the mouse event. If we reverse that argument, if
you are a subview that want to handle mouse events you're at the mercy
of your superviews. Ergo, the superview needs to take responsibility
for which view handles what, and in which order.
It was almost a year ago I last worked with views in detail, so I could
be mistaken on this though. Feel free to correct me if that's the case.
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.