handler to connect buttons with a line

James Hurley jhurley0305 at sbcglobal.net
Wed Nov 2 00:40:26 EDT 2011


Kresten,

I think I understand. The card script below will create n button and n * (n-1) connecting  lines.

As the buttons are moved the connecting lines follow.

Jim Hurley

local myNAME, n

on mouseDown
   put the  short name of the target into myName
   put 5 into n
   repeat with i = 1 to n
      put "radio"& i into tName
      if there is no button tName then
         create button tName
         set the style of button tName to "radioButton"
         set the width of button tName to 20
         set the loc of button tName to 20 + i*40,20
         set the borderWidth of button tName to 0
      end if 
   end repeat
   
   repeat with i = 1 to n
      repeat with j = i+1 to n
         put "line" & i & j into tName
         if there is no grc tName then
            create grc tName
            set the style of grc tName to "line"
            set the layer of grc tName to bottom
         end if
      end repeat
   end repeat
end mouseDown

on mouseMove x,y
   if myName is "" then exit mouseMove
   if not (myName  contains "radio")  then exit mouseMove
   set the loc of button myName to x,y
   repeat with i = 1 to n
      put "radio" & i into tStart
      repeat with j = i+1 to n
         put "radio" & j into tEnd
         put "line" & i & j into tName
         set the points of grc tName to the loc of button tStart & cr & the loc of button tEnd
      end repeat
   end repeat
end mouseMove

On mouseUp
   put  "" into myName
end mouseUp

on MouseLeave
   put "" into myName
end MouseLeave


> ------------------------------
> 
> Message: 6
> Date: Mon, 31 Oct 2011 15:38:03 +0100
> From: Kresten Bjerg <Kresten.Bjerg at psy.ku.dk>
> To: "use-livecode at lists.runrev.com" <use-livecode at lists.runrev.com>
> Subject: handler to connect buttons with a line
> Message-ID:
> 	<8962F0E4BD055148AA4051D91F7EB4A908F13C61BF at IBTMAIL2A.ibt.ku.dk.ad>
> Content-Type: text/plain; charset="us-ascii"
> 
> Hello
> I have been experimenting to create a handler (as button or menu), which will permit user
> 
> a)      To select two existing moveable button
> 
> b)      Create a line, attaching its endpoints to the buttons, so line will stay between them wherever they are positioned on the card.
> 
> c)       It is important that same button can be connected to more buttons, thus creating a simple user-built and editable mindmap.
> My experiments - I am lousy as a programmer - have  been of no avail.
> Could somebody help, and sketch a handler ?
> The context is that of extending the functionalities of a freeware patient/citizen diary  www.phenomenalog.dk<http://www.phenomenalog.dk>
> Best regards
> Kresten Bjerg  Kresten.bjerg at psy.ku.dk<mailto:Kresten.bjerg at psy.ku.dk>
> 





More information about the use-livecode mailing list