[comp.sys.mac.hypercard] key equivalents

kpmiller@uokmax.ecn.uoknor.edu (Kent P Miller) (03/19/91)

Can anyone tell me a quick way to assign key equivalents to buttons in
hypercard?  
ThankS
-- 
-----------------------
Kent Miller
KENT@aardvark.ucs.uoknor.edu
Bitnet -> KENT@uokucsvx

jk3t+@andrew.cmu.edu (Jonathan King) (03/19/91)

kpmiller@uokmax.ecn.uoknor.edu (Kent P Miller) writes:
> Can anyone tell me a quick way to assign key equivalents to buttons in
> hypercard?  

Two quick ways, both of which assume you are using HC 2.0 or higher.

(1)  Write an "on commandKeyDown" handler that traps the particular key
equivalents that should act the same as a button, and then does what
the button does.

(2)  If you are using HC 2.0 or above, then you can make up custom
menus (with command key equivalents) whose menuitems send messages
that could be the same as your button.  This may make more sense if
you want your user to be able to use a normal menu rather than just a
button.

An example of approach 1: 

on commandKeyDown which  --put this somewhere convenient
 if which is "R" then 
    global myfile    
    resort myfile
 else
    pass commandKeyDown
 end if
end commandkeyDown

on mouseup --the button you want a command key equiv for
 global myfile  
 resort myfile
end mouseup

on resort thefile
  --do your dance
end resort

As they say, nothing could be easier...

jking