mouseDown/mouseUp problem

Chipp Walters chipp at chipp.com
Wed Mar 16 02:40:35 CST 2005


Hi James,

For various reasons, it's not a good idea to use the 'repeat while the 
mouse is down' or even 'mouseStillDown' (check the archives as there's a 
lot of info on it)

I think you're better doing something like:

local lMouseIsDown

on mouseDown
  put true into lMouseIsDown
  send "doRepeat" to me in 30 milliseconds
end mouseDown

on doRepeat
  if lMouseIsDown then
     -->DO STUFF HERE
     send "doRepeat" to me in 30 milliseconds
  end if
end doRepeat

on mouseUp
  mouseRelease
end mouseUp

on mouseRelease
  put false into lMouseIsDown
  --> DO MOUSE IS UP STUFF
end mouseRelease

James Spencer wrote:
> I've got a button which, when it is pressed and held, I want to do some 
> things (brief and repetitive) and then do some other things once it is 
> released.  I've got handlers in the button script:
> 
> on mouseDown
>     repeat while the mouse is down
>         -- do stuff repeatedly while mouse is down
>     end repeat
>     -- do some quick cleanup code before exiting
> end mouseDown
> 
> on mouseUp
>     -- do stuff now that the button as been released
> end mouseUp


More information about the use-livecode mailing list