checkingMousedownDuration
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
checkingMousedownDuration
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
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
- Attachments
-
- CheckingMousedownDuration.livecode.zip
- (1.54 KiB) Downloaded 193 times
https://alternatic.ch
Re: checkingMousedownDuration
Jean Marc...
maybe..
be well
Dixie
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
Dixie
Re: checkingMousedownDuration
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
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
https://alternatic.ch
Re: checkingMousedownDuration
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 ...
EDIT: well, I suppose you can determine the length of time the mouse has been down if you employ mouseStillDown...
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
Re: checkingMousedownDuration
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
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
https://alternatic.ch
Re: checkingMousedownDuration
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.
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
to your handler
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
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
Re: checkingMousedownDuration
Hi Bernd,
Thanks
That confirm the pendingmessage is the best way for me.
Best regards
Jean-Marc
Thanks
That confirm the pendingmessage is the best way for me.
Best regards
Jean-Marc
- Attachments
-
- CheckingMousedownDuration001.livecode.zip
- (2.64 KiB) Downloaded 193 times
https://alternatic.ch