local tDown
on mouseDown
send checkMouse to me in 3 secs
end mouseDown
on checkMouse
put false into tDown
wait 1 sec
if tDown is true then answer "It was held down"
end checkMouse
on mouseStillDown
put true into tDown
end mouseStillDown
local sStartTime
on mouseDown
put the milliseconds into sStartTime
end mouseDown
on mouseUp
put the milliseconds - sStartTime into tTimeDiff
if tTimeDiff > 3000 and tTimeDiff < 6000 then -- between 3 and 6 seconds
-- process your mouseUp
answer "right time delay"
end if
end mouseUp
An elegant solution that works fine. However, I would prefer the processing to start after the 3 secs or whatever, while the mouse is still being held down. Can you see a way to do that?
local sStartTime
on mouseDown
put the milliseconds into sStartTime
send checkTime to me in 5 milliseconds
end mouseDown
on checkTime
put the milliseconds - sStartTime into tTimeDiff
if tTimeDiff < 3000 and the mouse is down then
send checkTime to me in 50 milliseconds
exit checkTime
end if
if tTimeDiff > 3000 and the mouse is down then
-- process your code
answer " right timeDelay"
end if
end checkTime