Re: Figuring out which NSView to send an event to
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