Subject: Re: Dragging Lines in a Field
Tariel Gogoberidze
PMDA at earthlink.net
Fri Apr 19 15:12:01 EDT 2002
>>Does anybody have a solution for dragging lines up and down in a field to
>> resort them?
>>Thanks,
>Ray Horsley
>Developer, LinkIt! Software
As a reply
Rich
Payne Sparkman Mfg.
shop at paynesparkman.com
Posted a script that allows to drag lines inside the field.
Posted a script that allows to drag lines inside the field.
I tested the script and it works, but unfortunately after intensive
use it eventually crushes MC v 2.4.2, at least on my computer (Mac OS
9.1 G3 350, 512 Meg RAM). One of the symptoms is that MouseStillDown
handler begins to indefinitely calling itself even long after the
mouse is UP (indefinite recursion, if I'm not messing up the terms). It
keeps calling MouseStillDown until the mouse is clicked outside the
field. So, I blocked this behavior with "click at -100,100" at the end
of the handler. This stopped MouseStillDown to continue working
after mouseup but MC 2.4 still crushes, through less frequently.
Without having exact recipe I think this has something to do with new
async behavior of mouse function
"The "mouse" function is now async rather than event based as in
previous releases. This means that "the mouse" will only return
"down" if the mouse is actually down at the exact instant the function
checks it."
So, I modified script a little (see below) and now it seems to be
stable in all versions of MC.
note: I'm sure it can be done in more efficient way, but I cooked it
very quickly and my goal was to just stabilize the script in MC 2.4.2
Local VertiMouse,MyTop,MyLeft,linHt,CurLinPtr,moveTxt,Actionflag
## you can set any margin for fld and have it with or without
vertical scrollbar
## button should have "showBorder" = false and name "DragLineBtn"
## field has list behavior.
on mouseDown
put "false" into Actionflag
pass mousedown
end mouseDown
on mousestillDown
if Actionflag is "false" then -- MouseStillDown should work only once
this way...
put the ClickLine into CkLn
put value(the ClickLine) into moveTxt
if moveTxt is empty then exit mousestillDown
delete line (word 2 of CkLn) of me
set the label of button "DragLineBtn" to MoveTxt
put the textHeight of me into linHt
## f you want custom cursor while dragging, create one and
activate lines below
--set the cursor to (the id of image "DragLineImg" of grp "DragLineGrp")
-- set the lockcursor to true
put 4 into MyTune
## Would love to know why but on my computer it needs this correction
## to let button fit exactly in Field boundaries. Put 0 into MyTune
if your
## OS/computer will not require correction
set the borderWidth of button "DragLineBtn" to the margins of me - MyTune
put the top of me into MyTop
put (the left of me) + MyTune into MyLeft
if the vScrollbar of me is "true" then
set the width of button "DragLineBtn" to (the width of me) - (the
scrollbarWidth of me) - (MyTune*2)
else
set the width of button "DragLineBtn" to (the width of me) - (MyTune*2)
end if
set the height of button "DragLineBtn" to LinHt
set the topLeft of button "DragLineBtn" to MyLeft,MyTop
set the visible of button "DragLineBtn" to true
--
put "true" into Actionflag -- so it never do it again while the
mouse is down
Send "dragLine" to me in 1 milliseconds
--
end if
end mouseStillDown
on dragLine
if the mouse is up then -- get out and exit
-- repeat for each line L in the pendingMessages
-- cancel (item 1 of L) -- not needed actually
-- end repeat
set the visible of button "DragLineBtn" to false
put ((VertiMouse - MyTop) div linHt)+1 into CurLinPtr
if the scroll of me > 0 then
add (the scroll of me div LinHt) to CurLinPtr
end if
if CurLinPtr > (number of lines in me) then
put cr&moveTxt after the last line of me
select the last line of me
else
put MoveTxt & cr before line CurLinPtr of me
select line CurLinPtr of me
end if
set the lockcursor to false
exit dragline
end if
--
put the MouseV into VertiMouse
put the scroll of me into temp
if VertiMouse < MyTop then
put MyTop into VertiMouse
subtract LinHt from temp
end if
if VertiMouse > the bottom of me then
put the bottom of me into VertiMouse
add LinHt to temp
end if
set the scroll of me to temp
set the topLeft of button "DragLineBtn" to MyLeft,VertiMouse-(LinHt
div 2)
---
send dragline to me in 10 milliseconds -- is 10 Milliseconds OK?
end dragline
Best regards
Tariel Gogoberidze
More information about the metacard
mailing list