Difference between revisions of "on.timer"
Jump to navigation
Jump to search
m |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The event '''on.timer''' is fired when a [[:Category:timer|timer]] is run. | + | The event '''on.timer''' is fired when a [[:Category:timer|timer]] is run (called periodically according to the period set in [[timer.start]]) |
It has no argument. | It has no argument. | ||
Line 28: | Line 28: | ||
</source> | </source> | ||
− | Check out the [http:// | + | Check out the [http://inspired-lua.org/index.php/2011/05/linking-events/ the full explanation of this example] in the tutorials part. |
[[Category:Events]] | [[Category:Events]] |
Latest revision as of 15:30, 17 December 2013
The event on.timer is fired when a timer is run (called periodically according to the period set in timer.start)
It has no argument.
Example
Below is an example of a program that displays a message for 1 second when a key is pressed.
function on.paint(gc)
if message then
gc:setFont("sansserif", "r", 10) -- initialize font drawing
gc:drawString(message, 0, 0, "top") -- display the message at (0, 0) coordinates
message = nil -- erase the message
timer.start(1) -- start a timer to exit on.paint() but keep in mind that we have to redraw the screen
end
end
function on.timer()
timer.stop()
platform.window:invalidate()
end
function on.charIn(ch)
message = "Hello World !" -- store a message
platform.window:invalidate() -- force display
end
Check out the the full explanation of this example in the tutorials part.