Re: click through view ?
Re: click through view ?
- Subject: Re: click through view ?
- From: RFM <email@hidden>
- Date: Tue, 19 Mar 2002 07:09:50 -0500
- Organization: RFM & Associates
Yep, that worked. This is what I did:
- (NSView*)hitTest:(NSPoint)point
{
NSView *hitView = [super hitTest:point];
// if the view clieck was self then ignore the click by returning nil
return (hitView == self) ? nil : hitView;
}
Thanks for the hint.
Regards,
Bob
email@hidden wrote:
>
> Can anyone tell me if it possible to implement an NSView that can be
>
> clicked through such that anything view lying 'underneath' can receive
>
> the click unless the subview of the click through view is hit ? I'm
>
> trying to create a view that is essentially transparent yet houses
>
> subviews, so that if the actual view itself is hit the click is ignored
>
> and passed to the next view in the hierarchy unless a subview is hit of
>
> course.
>
>
The doc for -[NSView hitTest:] says:
>
>
> Returns the farthest descendant of the receiver in the view hierarchy
>
> (including itself) that contains aPoint, or nil if aPoint lies
>
> completely outside the receiver. aPoint is in the coordinate system of
>
> the receiver's superview, not of the receiver itself.
>
>
>
> This method is used primarily by an NSWindow to determine which NSView
>
> should receive a mouse-down event. You'd rarely need invoke this
>
> method, but you might want to override it to have a view object hide
>
> mouse-down events from its subviews.
>
>
Based upon this, I think overriding hitTest: and returning nil when
>
desired should do what you want. However, I haven't tried; I've
>
overridden hitTest: for other purposes, but I've never done what you
>
suggest. A report to the list on your experiences might be nice!
>
>
Ben Haller
>
Stick Software
_______________________________________________
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.