boz@eleazar.dartmouth.edu (John Boswell) (05/31/88)
I've been trying to get the "popup menus" demonstration from the latest MacTutor to work. Everything works fine, with the following exception: set editbkgnd to true domenu "New Field" set name of bkgnd field "New Field" to theName This doesn't work, since unlike "New Button", there is no default name for a "New Field". Thus I have to put the following line after domenu: set the name of the target to "New Field" but this doesn't work as expected!!! It seems that what is returned for "target" is the CARD id!!! If I do: get the target put it after domenu, i get "card id 3276" or whatever in the msg box!!! What gives??? HOW do I set the name of this bkgnd field to "New Field" so the rest of this script will work??? ANY help will be *greatly* appreciated!! Thanks, John Boswell Dept. of Chemistry Dartmouth College boz@eleazar.dartmouth.edu
edmoy@violet.berkeley.edu (06/01/88)
In article <8724@dartvax.Dartmouth.EDU> boz@eleazar.dartmouth.edu (John Boswell) writes: >What gives??? HOW do I set the name of this bkgnd field to "New Field" so >the rest of this script will work??? I think this should work. Try: set name of last bkgnd field to theName This relies on new fields being put last in the list. Edward Moy Workstation Software Support Group University of California Berkeley, CA 94720 edmoy@violet.Berkeley.EDU ucbvax!violet!edmoy
jgreely@kazoo.cis.ohio-state.edu (J Greely) (06/01/88)
In article <8724@dartvax.Dartmouth.EDU> boz@eleazar.dartmouth.edu (John Boswell) writes: > This doesn't work, since unlike "New Button", there is no default >name for a "New Field". Thus I have to put the following line after >domenu: > >set the name of the target to "New Field" > >but this doesn't work as expected!!! Ah, yes. "Name of the target". I ran into this mess when I wanted to say "number of lines in the target", which returns 1. The correctly convoluted syntax turned out to be "number of lines in field short name of the target". Unfortunately, your field doesn't have a name. My initial suggestion was that you try 'set the name of field id the target to "New Field"'. This is wrong. Firing up HyperCard revealed that the following script achieves what you want (in 1.1): on MouseUp put last word of the target into temp set name of field ID temp to "New Field" end MouseUp If you try just saying 'set name of field ID last word of the target to "New Field"', the name will change, but the script will bomb. Apparently you cannot change "name of the target" directly. > It seems that what is returned for >"target" is the CARD id!!! If I do: Your other problem (testing in the message box) is buried in Goodman's monster ("Volume 2 (I cut my copy in half at Part Three), pg. 557): "If you try typing _the_target_ into the message box, it will always return the current card's ID number, ..." -=- (jgreely@cis.ohio-state.edu; ...!att!cis.ohio-state.edu!jgreely) Team Wheaties says: "Just say NO to rexd!" /^Newsgroups: .*\,.*\,.*\,/h:j /[Ww]ebber/h:j /[Bb]irthright [Pp]arty/j /[Pp]ortal/h:j
winkler@Apple.COM (Dan Winkler) (06/01/88)
That's right, after a doMenu "new field" you can refer the field as "last field" or "last card field" if it's a card field. The same approach works for buttons. The target is the object to which the message that is currently being handled was sent. If handler "foobar" examines "the target" it will find out which object was first sent "foobar" before it inherited down to its current handler. The target does not change during the execution of handler. There is nothing a handler can do (you'd be surprised by what people have tried) to change what it gets when it evaluates "the target" Dan.
mike@ninja.cc.umich.edu (Michael Nowak) (06/21/88)
In article <8724@dartvax.Dartmouth.EDU> boz@eleazar.dartmouth.edu (John Boswell) writes: > > I've been trying to get the "popup menus" demonstration from the >latest MacTutor to work. Everything works fine, with the following >exception: > >set editbkgnd to true >domenu "New Field" >set name of bkgnd field "New Field" to theName > > This doesn't work, since unlike "New Button", there is no default >name for a "New Field". If you put the following in the script for the card or stack, all your new fields will be named "New Field" when they are created: on newField set the name of the target to "New Field" end newField "the target" contains the name of the object which original got the message. I assume that your script is in a card so it is naturally the target. The newField handler will intercept the newField message which was originally sent to the field so in the context of that script, the target is the name of the field. ------------------------------------------------------------------------------ In Real Life: Michael Nowak Workstation Consultant U of M Computing Center User Services Via Internet: mike@ninja.cc.umich.edu Via UUCP: uunet!umix!ninja.cc.umich.edu!mike Working for but in no way representing the University of Michigan. ------------------------------------------------------------------------------