• 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: Figuring out which NSView to send an event to
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Figuring out which NSView to send an event to


  • Subject: Re: Figuring out which NSView to send an event to
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 04 Sep 2012 08:41:07 -0500

On Sep 4, 2012, at 8:20 AM, Graham Cox wrote:

> On 04/09/2012, at 9:28 PM, Akhil Jindal <email@hidden> wrote:
>
>> Using NSWindowList, and iterating over them, I find the window to which the
>> event should belong. Now I have to find the NSView within the window.
>
> Ask the window for its firstResponder. That should be the object that events get directed to. It might not be a view but usually is. In any case it will be an NSResponder.
>
> Rather than iterating over the windows it also would probably be better to ask NSApp for its mainWindow (or keyWindow) then that window's firstResponder.

This would only be appropriate for events that don't have an inherent position, like key events.  For events from a tablet, which do have a position, the first responder is not the appropriate target.  This is just like for a mouse.  Certainly, you don't expect a click outside of the main or key window, or on a button when a text field is the first responder, to only go to the first responder, do you?

Regards,
Ken


_______________________________________________

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

  • Follow-Ups:
    • Re: Figuring out which NSView to send an event to
      • From: Graham Cox <email@hidden>
References: 
 >Figuring out which NSView to send an event to (From: Akhil Jindal <email@hidden>)
 >Re: Figuring out which NSView to send an event to (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Figuring out which NSView to send an event to
  • Next by Date: How to Identify a "Phantom" Write Operation
  • Previous by thread: Re: Figuring out which NSView to send an event to
  • Next by thread: Re: Figuring out which NSView to send an event to
  • Index(es):
    • Date
    • Thread