Dragging a line between points

Richard K. Herz herz at ucsd.edu
Thu Jul 31 18:02:02 EDT 2003


"T. R. Ponn" <alptex2 at orwell.net> wrote:

> I've been fiddling with this all afternoon...and I have to be missing
> something obvious.  How do I click on one button (representing a "Pin"
> on a connector) and have a straight line follow the mouse until I click

Well, I didn't exactly as you asked but this should get you started
(irritating technique I use on my students ;-)

Rich Herz
herz at ucsd.edu

# script of stack with a graphic "Pin 1"
global gWireEnds, gDrawWire, gWires

on mouseDown
  if the mouseLoc is within the rect of graphic "Pin 1" then
    put the mouseLoc into gWireEnds
    set the style of the templateGraphic to "line"
    # increment wire count
    if gWires is not a number then
      put 1 into gWires
    else
      add 1 to gWires
    end if
    put "wire" && gWires into tWire
    create graphic tWire
    put "true" into gDrawWire
  end if
end mouseDown

on mouseRelease
  # use mouseRelease since mouse may go up outside graphic
  if gDrawWire is "true" then
    put "false" into gDrawWire
    # create a new pin
  end if
end mouseRelease

on mouseMove
  if gDrawWire is "true" then
    put the mouseLoc into line 2 of gWireEnds
    put "wire" && gWires into tWire
    set the points of graphic tWire to gWireEnds
  end if
end mouseMove





More information about the use-livecode mailing list