[comp.sys.mac.hypercard] self-knowing scripts possible?

emcguire@ccad.uiowa.edu (Ed McGuire) (01/19/91)

The user interface for a card I'm writing dynamically arranges various
buttons on the card.  Thus, a button may be anywhere on the card when
it is pressed.  A button unhides an associated field.  I want the field
to appear below the button.  That's the part that has me stumped.

If the button script could learn the identity of the button that has it,
this would be easy.  I could then get the position of the button.  I
could even write the code for displaying the field in the card instead
of duplicating it in each button, thus saving a lot of code duplication.

Is there some means for a script to learn the identify of its holder
button, field, card, whatever?  Is there another approach I have not
considered?  I'd be grateful for either HC1 or HC2 ideas.
-- 
peace.  -- Ed
"Over here, Bones!  This man's dying!"
"Damn it, Jim!  I'm a doctor, not a . . .  What did you say?"

dmittman@beowulf.JPL.NASA.GOV (David Mittman) (01/19/91)

When the user clicks on an object (Button, Field, Card), the
container "target" contains the identification of that object.
The script you want to use would look something like this:
     
on mouseUp
  set the top of cd fld 1 to the bottom of the target
  set the left of cd fld 1 to the left of the target      
end mouseUp
                                                 
This is just a very rough script. If you need more assistance,
please don't hesitate to ask.
 
                                        - David

P.S. As always, the documentation is many times the most 
     definitive source for HyperTalk languauge definitions.
     Note that there is some discussion to be found in the
     documentation which outlines the somewhat esoteric 
     differences between "the target" and "target".

jkc@Apple.COM (John Kevin Calhoun) (01/19/91)

In article <1991Jan18.164956.22659@ccad.uiowa.edu> emcguire@ccad.uiowa.edu
(Ed McGuire) writes:
>If the button script could learn the identity of the button that has it,...
>I could then get the position of the button.

>Is there some means for a script to learn the identify of its holder
>button, field, card, whatever?

Yes.  You can, for example, get 'the rect of me', to get the position
of a button whose script is executing.

Kevin Calhoun
HyperCard Team
Apple Computer, Inc.

dlugose@uncecs.edu (Dan Dlugose) (01/19/91)

In article <1991Jan18.164956.22659@ccad.uiowa.edu> emcguire@ccad.uiowa.edu (Ed McGuire) writes:
>Is there some means for a script to learn the identify of its holder
>button, field, card, whatever?  Is there another approach I have not
>considered?  I'd be grateful for either HC1 or HC2 ideas.
 
  put the name of me into x -- gives for example "card button help"
  put the short name of me -- "help"
  put the rect of me -- rect of where I currently am

Dan Dlugose
UNC Educational Computing Service
-- 
Dan Dlugose
Internet: dlugose@uncecs.edu
UNC Educational Computing Service
Box 12035, Research Triangle Park, NC 27709-2035