Re: Connecting actions to menu
Re: Connecting actions to menu
- Subject: Re: Connecting actions to menu
- From: jgo <email@hidden>
- Date: Thu, 21 Jun 2001 21:52:19 -0700
>
Carlos Weber wrote:
>
John, I am a cocoa newbie also. This "first responder" notion was
>
one of the most difficult things to wrap my mind around. Here's
>
how I understand it (others please feel free to correct me in case
>
I still haven't wrapped my mind around it!):
>
>
Designating the first responder object as the target of an (e.g., menu)
>
action is a way of telling the dispatch system (consisting, I think, of
>
code in NSResponder, NSApplication, and the ObjC runtime) that you are
>
designating an "id" to perform the action method, that the "id" is to
>
located and bound dynamically (at runtime), and that the way to locate
>
the particular "id" in question is to look at each object in the
>
responder chain until you find one that implements the designated action
>
method. In fact this is how menu items know whether they should enable
>
themselves or not! When I first figured out how this worked I was
>
dumbstruck by how cool and elegant it is...
Thanks for responding, Carlos.
This appears to be another example of my thinking being along
a completely different curve from the pack.
The idea of a responder chain is elementary. An object can
handle an event related to it directly... or pass it up the
chain, or the task of responding might be passed off to a
completely different chain. The question of "What is the first
responder?", to me is "When this happens in this context, what
is the first object that should get a shot at responding?"
But context changes, so the first responder changes; it's
dynamic, not static, context dependent, not universal.
If I click on a button (which is a view which is a responder),
the button is likely to be the first responder. If I type in
a TextView, the text view is likely to be the first object to
properly have a shot at responding. If I click on a pop-up
that is in a different view from the aforementioned button,
it (being a view, being a responder) is likely to be its own
first responder, and to have a different responder chain (because
it is in a different view hierarchy)... but, in each case, the
object mentioned doesn't have to be its own first responder.
As I understand it, we have the option of setting it up so that
the first responder for the button is something completely different.
Please correct, clarify, expand.
John G. Otto Nisus Software, Engineering
www.infoclick.com www.mathhelp.com www.nisus.com software4usa.com
EasyAlarms PowerSleuth NisusEMail NisusWriter MailKeeper QUED/M
Will program Macs for food.