I'm working on creating a stack to analyze text files with the scripts of other stacks to show their flow and how the scripts are connected.
The image shows the output so far, and I want the user to be able to drag the graphic objects to create a more pleasing layout. When the user lets go of a graphic, the doLines function stretches all the connecting lines to the new position and then saves the location of the 20 graphics to a custom property. I originally had the doLines code in the mouseMove handler, but separated it out because I thought that was the cause of the slowdown.
The code shown is set as a behaviour for the 20 graphic objects shown. With the connecting lines, there are about 50 graphics on the card. The issue is that the code is responsive and works fine on the first graphic, but then things slow down drastically and it is hard to choose or move another object. I borrowed the code setting the gDragging flag and using the Deltas from an old website - Is it outdated now?
I tried using "grab me" but I couldn't figure out how to let go of the object once I started dragging it. The flush events calls were another attempt to speed up the second call.
Summary - need help to find out why it works poorly the second time it is called. Any suggestions?
Code: Select all
local tName,gDeltaX,gDeltaY
global gDragging,tList
on mouseDown
put the short name of the target into tName
if char 1 of tName is not "G" then exit mouseDown
put true into gDragging
put item 1 of the loc of the target - the mouseH into gDeltaX
put item 2 of the loc of the target - the mouseV into gDeltaY
end mouseDown
on mousemove x,y
put flushEvents("all")
if gDragging = true then
add gDeltaX to x
add gDeltaY to y
set the loc of the target to x,y
end if
end mousemove
on mouseUp
put false into gDragging
put flushEvents("all")
recordLoc
end mouseUp
on recordLoc
put empty into tList
repeat with x = 1 to the number of graphics
put the short name of grc x into tName
if char 1 of tName is not "G" then next repeat
delete char 1 of tName
put the loc of grc x into line tName of tList
end repeat
set the cLocList of button "Chart" to tList
send "doLines" to button "Chart"
end recordLoc