handler to connect buttons with a line

Richmond richmondmathewson at gmail.com
Mon Oct 31 15:11:06 EDT 2011


On 10/31/2011 07:25 PM, Jim Lambert wrote:
> Kresten,
>
>>   Create a line, attaching its endpoints to the buttons, so line will stay between them wherever they are positioned on the card.
Well, it doesn't feature live updating, by I did thi2:

created a card, with a graphic object "Line", and 2 buttons, "Button" 
and "Button1" respectively [I made
them 24 x 24 squares, set their labels to an empty space and coloured 
them red].

made a field called "VL'

put this script in "Button":

on mouseDown
   grab me
end mouseDown

on mouseUp
   put the mouseLoc into VL1
   set the loc of me to VL1
   put the loc of btn "Button" into line 1 of fld "VL"
   put the loc of btn "Button1" into line 2 of fld "VL"
   set the points of graphic "line" to fld "VL"
end mouseUp

and, surprise, surprise, this script in "Button1":

on mouseDown
   grab me
end mouseDown

on mouseUp
   put the mouseLoc into VL2
   set the loc of me to VL2
   put the loc of btn "Button" into line 1 of fld "VL"
   put the loc of btn "Button1" into line 2 of fld "VL"
   set the points of graphic "line" to fld "VL"
end mouseUp


if you are really excited about this (har, har) I can send you the stack 
off-list.
Although it would be dead easy to do it yourself.

Richmond.




More information about the use-livecode mailing list