90_GRAZA%UNION.BITNET@MITVMA.MIT.EDU (05/19/88)
--Easy Buttons, By Jason Grazado, 5/18/88
--This script enables you to have simple control over all your buttons
--If you paste it in to your Card/Background/Stack/Home Card you will
--be able to do the following to buttons within the realm that this
--script has control of, while still using the 'browse' tool:
-- 'Pop Open' its script by clicking with the command key down
-- Reposition it by holding down the option key and dragging it
-- constrain movement by holding down the shift key along w/option
--
--It is useful as you can manipulate buttons scripts while testing
--a stack without having to continuously choosing the button tool.
--
--It also, via a On NewButton script, sets the script of every new
--to allow for your own mousedown and mousestilldown scripts as long
--as they do not require the use of modifier keys.
--
--It is pretty much self explainatory...but is probably very unorthodoxed
--so if anyone has good ideas for improvements, features, bug fixes or
--speed improvement, feel free to modify it, but send me a copy so I
--might learn something.
--
--I hope some people might find it useful...but if you don't really
--understand hierarcy withing hypercard, I suggest you be careful with
--it. Good Luck.
-- Jason Grazado
-- 90_grazadoj@union.bitnet
--
--P.S.
-- Sorry its so long.......
on mousedown
global diffX,DiffY,ShiftDir,targloc
if the commandkey is down then edit script of the target
if the optionkey is not down then exit mousedown
put the loc of the target into TargLoc
put (item 1 of TargLoc - item 1 of the clickloc) into diffX
put (item 2 of TargLoc - item 2 of the clickloc) into diffY
if the shiftkey is down then
GetShiftDir
else
put "" into shiftDir
end if
end mousedown
on mousestilldown
global TargLoc,DiffX,Diffy,shiftDir
if the optionkey is not down then exit mousestilldown
if shiftDir is "H" then
--confine along horizontal exis
put (item 1 of the mouseloc + diffX) & "," & (item 2 of TargLoc) B
into NewLoc
else
if shiftDir is "V" then
--confine along vertical axis
put (item 1 of TargLoc) & "," & (item 2 of the mouseloc+ diffY) B
into NewLoc
else
--Do not restrain movement at all
put (item 1 of the mouseloc + diffX) & "," & (item 2 of the mouselocB
+ diffY) into NewLoc
end if
end if
set the loc of the target to NewLoc
end mouseStillDown
on GetShiftDir --Which Axis Restrain?
global shiftdir
put abs(item 1 of the mouseloc - item 1 of the clickloc) into Horiz
put abs(item 2 of the mouseloc - item 2 of the clickloc) into Verti
if horiz is verti then
getnewdir
else
if horiz > verti then
put "H" into shiftdir
else
put "V" into shiftdir
end if
end if
end GetShiftDir
on modifier
global ismodified
if the shiftkey is down or the commandkey is down or the optionkey isB
down then
put true into isModified
else
put false into isModified
end if
end modifier
on newbutton
put the name of the target into NewTarget
put "On MouseDown" & return after NewScript
put "global IsModified" & return after NewScript
put "Modifier --Check for Sft/Cmd/Opt Keys down" & Return B
after NewScript
put "if isModified is true then pass MouseDown --to the stack" & return B
after NewScript
put Return after NewScript
put "--your MouseDown script begins here" & return & returnB
after NewScript
put "End MouseDown" & return & Return & Return after NewScript
put "On MouseUp" & return & return after NewScript
put "End MouseUp" after NewScript
set the script of NewTarget to NewScript
end newbutton
--Oops...change all those random capital B's to option-return characters in
HC.