Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
I have this simple count up script... The bug happens when you multiple times click on the start/stop buttons in very short time... Than the clock goes crazy...
I need to somehow block the count up script if the button is pressed more than 1 time in 1 second. Any ideas?
on mouseUp
put "Start Clock" into startLabel
put "Stop Clock" into stopLabel
if the label of me is startLabel then
set the label of me to stopLabel
set the backgroundcolor of me to green
DoCountUp
else
set the label of me to startLabel
set the backgroundcolor of me to red
end if
end mouseUp
on DoCountUp
put "Start Clock" into startLabel
put "Stop Clock" into stopLabel
if the label of ME is stopLabel then
set the numberformat to 00
add 1 to field GameClockSec
if field GameClockSec = 60 then
add 1 to field GameClockMin
put 00 into field GameClockSec
else
end if
send "DoCountUp tNewTime" to me in 1 second
end if
end DoCountUp
local holdTime
on mouseUp
put "Start Clock" into startLabel
put "Stop Clock" into stopLabel
if the label of me is startLabel and the ticks - holdTime >30 then --NEW
set the label of me to stopLabel
set the backgroundcolor of me to green
put the ticks into holdTime -- NEW
DoCountUp
else
set the label of me to startLabel
set the backgroundcolor of me to red
end if
end mouseUp
on DoCountUp
put "Start Clock" into startLabel
put "Stop Clock" into stopLabel
if the label of ME is stopLabel then
set the numberformat to 00
add 1 to field GameClockSec
if field GameClockSec = 60 then
add 1 to field GameClockMin
put 00 into field GameClockSec
else
end if
send "DoCountUp tNewTime" to me in 1 second
end if
end DoCountUp
local holdTime
on mouseUp
put "Start Clock" into startLabel
put "Stop Clock" into stopLabel
if the label of me is startLabel then
set the label of me to stopLabel
set the backgroundcolor of me to green
put the ticks into holdTime -- NEW
DoCountUp
else
set the label of me to startLabel
set the backgroundcolor of me to red
cancel item 1 of last line of the pendingMessages ---NEW---
end if
end mouseUp
That should prevent multiple "DoCountUp" messages being sent