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 simple count up code for my clock, and it works good but when I click (and hold or move) on border of the window it pause counting up until I release mouse click. How to 'fix' this to work ALL the time?
Here is my code:
set the numberformat to 00
add 1 to field ClockSec of card controller
if field ClockSec of card controller = 60
then
add 1 to field ClockMin of card controller
put 00 into field ClockSec of card controller
else
end if
on mouseUp
If the label of ME is "Start" then
set the label of ME to "Stop"
set the backgroundcolour of ME to red
DoCountUp
else
set the label ME to "Start"
set the backgroundcolour of ME to green
end if
end mouseUp
on DoCountUp
if label of ME is "Stop"
then
set the numberformat to 00
add 1 to field GameClockSec of card controller
if field GameClockSec of card controller = 60
then
add 1 to field GameClockMin of card controller
put 00 into field GameClockSec of card controller
else
end if
send "DoCountUp tNewTime" to me in 1 second
end if
end DoCountUp
You can't do what you want. When you drag a window, the IDE locks up until you release the mouse. However, there are smarter ways to update a time display. Here's an example:
local lStartTime
on updateTime
if lStartTime is empty then
put the seconds into lStartTime
end if
put the seconds - lStartTime into myLapsedSeconds
put myLapsedSeconds div 60 into myMinutes
put myLapsedSeconds mod 60 into mySeconds
put myMinutes & colon & mySeconds into fld "Time"
// there are better ways to do this, but this is just an example
send "updateTime" to me in 500 milliseconds
end updateTime
on stopTime
put the pendingMessages into myMessages
filter myMessages with "*updateTime*"
repeat for each line myMsg in myMessages
cancel item 1 of myMsg
end repeat
end stopTime
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
on mouseUp
If the label of ME is "Start" then
set the label of ME to "Stop"
set the backgroundcolour of ME to red
updateTime
else
set the label ME to "Start"
set the backgroundcolour of ME to green
stopTime
end if
end mouseUp
If you use my example, you'll need a field with the name "Time".
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
You should use Mark's updateTime calculation because it calculates the correct time increase based on the current time, which will prevent errors in the time display.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Even "mouseMove" is not sent when the cursor is outside the rect of the card window, or that could be exploited. I wonder if that would be a nice feature, to have it in fact do so.
Anyway, I am with Jacque; what are you looking to do?
I have some count up timers in my stack and when you click on the title bar of an app, it pauses the count up timer. So I thought maybe I can do that count up code when the mouse is down on title bar...