• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to forward mouse events to another view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to forward mouse events to another view?


  • Subject: Re: How to forward mouse events to another view?
  • From: Ivan Kourtev <email@hidden>
  • Date: Sun, 15 Oct 2006 23:23:58 -0400

Thanks, I think I am finally starting to get it. If I subclass view B and implement hitTest, I can have the events passed to the containing view A when I want.


In trying to completely understand how this mechanism works, I read the dev. docs at http://developer.apple.com/documentation/Cocoa/ Conceptual/CocoaViewsGuide/SubclassingNSView/ chapter_5_section_4.html: "The window determines which view in the view hierarchy to send the mouse-down event using the NSView method hitTest:. Once the correct view is located, it is sent a mouseDown: event."


Is there anyone who can explain what exactly does the first sentence above mean? Does it mean that:

(a) The window send hitTest to every view and then somehow aggregates the answers and decides who to dispatch the event to?

(b) The window sends hitTest only to the views under the hit point. if this is the case, in what order are hitTest's sent -- from containing to subviews or vice versa or in a random order?

I did a little experimenting and it seems all views get hitTest, even when the click is outside of them.

--
ivan


On Oct 15, 2006, at 6:01 PM, Stephen Deken wrote:

Ivan,

I have a view A containing another view B. I want to have mouse events within B be handled by B in some situations or by the containing view A in others.

Look at NSView's -hitTest: method.

http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Classes/NSView_Class/Reference/Reference.html#// apple_ref/occ/instm/NSView/hitTest:

Stephen Deken
email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >How to forward mouse events to another view? (From: Ivan Kourtev <email@hidden>)
 >Re: How to forward mouse events to another view? (From: Stephen Deken <email@hidden>)

  • Prev by Date: Re: Custom dimmed graphic for NSButton?
  • Next by Date: Re: KVC Problems with Indexed Accessor - (A Solution)
  • Previous by thread: Re: How to forward mouse events to another view?
  • Next by thread: customizing NSCoding of NSDecimalNumber
  • Index(es):
    • Date
    • Thread