mouse tracking blues

Dave Cragg dcragg at lacscentre.co.uk
Tue Jul 9 17:56:01 EDT 2002


At 10:03 pm +0000 9/7/02, jbv wrote:
>Hi list,
>
>First I want to point out that I've read the archives
>and am aware of Scott's advice to not use a repeat
>loop inside a mousedown handler, but to use
>mousemove / mouserelease instead.
>
>However, I'm facing a problem for which using
>a repeat loop inside a mousedown seems to be the
>only solution, and of course I met the problem of
>the mouseup event not being trapped by my script.

<snip>

>It is obvious that I can't use mousemove, since the image must
>keep scrolling even when the mouse isn't moving, as long
>as it is down.

But you could use "send ... in" to control the moves, and mouseMove 
to track the mouse position. Something like:


local sHaveAction, sMV, sMH

on mouseDown
   put true into sHaveAction
   put the mouseH into sMH
   put the mouseV into sMV
   myAction
end mouseDown

on mouseUp
   put false into sHaveAction
end mouseUp

on mouseRelease
   put false into sHaveAction
end mouseRelease

on mouseMove x,y
   if sHaveAction then
    put x into sMH
    put y into sMV
   end if
end mouseMove

on myAction
   if sHaveAction
    ##do your move stuff here
   ## using smH and sMV as the current mouse coordinates
    send "myAction" to me in 50 milliseconds ##adjust time to taste
  end if
end myAction

Cheers
Dave Cragg



More information about the metacard mailing list