Page 1 of 1
checkingMousedownDuration
Posted: Tue Jul 03, 2012 6:48 pm
by jmburnod
Hi All,
I try to have two messages for a mousedown.
One if the duration of the mousedown < 2 seconds and one if > 2 seconds
I explored two ways :
One with a repeat loop
One with a "send message in" (pendingmessage)
What is the best for you ?
Best regards
Jean-Marc
Re: checkingMousedownDuration
Posted: Tue Jul 03, 2012 6:58 pm
by Dixie
Jean Marc...
maybe..
Code: Select all
local tStart
on mouseDown
put the millisecs into tStart
end mouseDown
on mouseUp
put the millisecs - tStart into theTimeTaken
if theTimeTaken > 2000 then
answer "Took more than 2 seconds"
else
answer "Took less than 2 seconds"
end if
end mouseUp
be well
Dixie
Re: checkingMousedownDuration
Posted: Tue Jul 03, 2012 7:13 pm
by jmburnod
Dixie,
Sorry i'm not clear.
I want 2 messages for one mousedown.
If the user keep the mousedown < 2 seconds the script send "doMes1"
If the user keep the mousedown > 2 seconds the script send "doMes2"
Thank one more for your time
Be well
Jean-marc
Re: checkingMousedownDuration
Posted: Tue Jul 03, 2012 7:18 pm
by Dixie
Jean-Marc...
That's what the script does !... as you can't determine the length of time the mouse has been down until it has been released ?!.. replace the answer command with the name of the handler to go to ...
Code: Select all
local tStart
on mouseDown
put the millisecs into tStart
end mouseDown
on mouseUp
put the millisecs - tStart into theTimeTaken
if theTimeTaken > 2000 then
domess1
else
domess2
end if
end mouseUp
EDIT: well, I suppose you can determine the length of time the mouse has been down if you employ mouseStillDown...
Re: checkingMousedownDuration
Posted: Tue Jul 03, 2012 8:03 pm
by jmburnod
Dixie...
Yes, you're right but i want the same result without mouseup
For example:
if the user clic before 2 seconds DoMes1 put the name of the target into a fld
If the user keep the mouse down 2 seconds the DoMes2 show a group
and the user can choose a control of this group without mouseup. The mouseup
is sent by the choosed control of the group.
Jean-Marc
Re: checkingMousedownDuration
Posted: Tue Jul 03, 2012 9:08 pm
by bn
Hi Jean-Marc,
I know you have special reasons to do things differently at times.
here is a way to do this just on mouseDown, essentially what Dixie did, just without mouseUp.
Code: Select all
local sStartTime
on mouseDown
put the milliseconds into sStartTime
send "checkMouse" to me in 0 milliseconds
end mouseDown
on checkMouse
if the mouse is up then
if the milliseconds - sStartTime < 2000 then
set the backgroundcolor of grc 1 to red
else
set the backgroundColor of grc 1 to blue
end if
exit checkMouse
end if
if "checkMouse" is not in the pendingMessages then
send "checkMouse" to me in 16 milliseconds
end if
end checkMouse
obviously you would want to change the conditional.
Kind regards
Bernd
Edit: if you don't want to let mouseUp or mouseRelease travel up the message hierarchy then you would have to add
Code: Select all
on mouseUp
end mouseUp
on mouseRelease
end mouseRelease
to your handler
Re: checkingMousedownDuration
Posted: Tue Jul 03, 2012 10:12 pm
by jmburnod
Hi Bernd,
Thanks
That confirm the pendingmessage is the best way for me.
Best regards
Jean-Marc