[comp.sys.next] actions and targets

mrc@Tomobiki-Cho.CAC.Washington.EDU (Mark Crispin) (04/21/89)

I just discovered something rather interesting.  If you have a panel
that is modally run from your MyApp object, the target of any cells in
the panel is set to that object by default.  This leads you into
mistakenly believing that you can set up actions for cells just by
calling setAction:.

This is not true.  It turns out that if you fire up a panel from some
other object (even modally) the target is set to nil and nothing will
happen.

I don't see this behavior documented anywhere.

Mark Crispin / P.O. Box 2652 / Seattle, WA 98111-2652 / (206) 842-2385
mrc@Tomobiki-Cho.CAC.Washington.EDU / MRC@WSMR-SIMTEL20.Army.Mil
450cc Rebel pilot -- a step up from 250cc's!!!
kisha no kisha ga kisha de kisha-shita...tabesaserarenakerebanaranakattarashii

ali@polya.Stanford.EDU (Ali T. Ozer) (04/21/89)

In article <1674@blake.acs.washington.edu> Mark Crispin writes:
> ... .  It turns out that if you fire up a panel from some
>other object (even modally) the target is set to nil and nothing will
>happen.
>
>I don't see this behavior documented anywhere.

If the target of an object is nil, then the action is sent to the 
first responder. This is how you can get document-specific menu commands
such as cut, copy, paste, save, save as, etc to send their actions to
the active window --- just set their targets to nil, and the commands
will go to the first responder chain, which starts off with the first
responder of the current window. (This will usually be your document object;
a subclass of view or whatever it is...) 

You mentioned that the target was getting set to the MyApp object when the
panel was run modally; you might want to check to see if the target
is getting set explicitly (which shouldn't be the case) or if you are
just seeing first-responder behaviour.

Ali Ozer, NeXT Developer Support
aozer@NeXT.com