Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
grovecat
- Livecode Opensource Backer
![Livecode Opensource Backer Livecode Opensource Backer](./images/ranks/forum-badge-tiny.png)
- Posts: 99
- Joined: Thu Aug 04, 2011 10:32 am
- Location: Albany, Western Australia
Post
by grovecat » Thu Feb 07, 2013 10:11 am
I need to ignore a button press unless it is held for more than a couple of seconds and I tried the following code, which does not work.
Code: Select all
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
Help appreciated.
TIA
Don
-
bn
- VIP Livecode Opensource Backer
![VIP Livecode Opensource Backer VIP Livecode Opensource Backer](./images/ranks/vip-forum-badge-tiny.png)
- Posts: 4038
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Post
by bn » Thu Feb 07, 2013 11:00 am
Hi Don,
try this
Code: Select all
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
Kind regards
Bernd
-
grovecat
- Livecode Opensource Backer
![Livecode Opensource Backer Livecode Opensource Backer](./images/ranks/forum-badge-tiny.png)
- Posts: 99
- Joined: Thu Aug 04, 2011 10:32 am
- Location: Albany, Western Australia
Post
by grovecat » Thu Feb 07, 2013 11:14 am
Thanks Bernd
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?
Cheers
Don
-
bn
- VIP Livecode Opensource Backer
![VIP Livecode Opensource Backer VIP Livecode Opensource Backer](./images/ranks/vip-forum-badge-tiny.png)
- Posts: 4038
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Post
by bn » Thu Feb 07, 2013 11:25 am
Hi Don,
try this
Code: Select all
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
Kind regards
Bernd
-
grovecat
- Livecode Opensource Backer
![Livecode Opensource Backer Livecode Opensource Backer](./images/ranks/forum-badge-tiny.png)
- Posts: 99
- Joined: Thu Aug 04, 2011 10:32 am
- Location: Albany, Western Australia
Post
by grovecat » Thu Feb 07, 2013 11:28 am
That is exactly what I needed.
Thanks again Bernd.
Cheers
Don