FixGUI Documentation
Back to summary
import "gui/view";
Timer class
Timer allows to run code repeatedly or with a given delay.
It can be used in multiple modes. You can either provide the callback directly or you can
subclass the Timer class to override the run
method.
Initialization
static function create(interval: Integer): Timer
static function create(interval: Integer, callback, data): Timer
-
Creates a new timer. You can also directly provide a callback to avoid the need
to override the run method. The callback takes a single parameter (data) and
should return
true
to continue running of the timer.
static function run(interval: Integer, callback, data): Timer
static function run_once(delay: Integer, callback, data): Timer
-
Creates a new timer with given callback and automatically starts it. The callback
takes a single parameter (data) and should return
true
to continue
running of the timer (unless the once
variant was used).
Properties
function get_interval(): Integer
-
Returns the interval in milliseconds.
function set_interval(interval: Integer)
-
Sets the interval in milliseconds. If the new interval is different from the current
interval and the timer is active the timer is restarted.
function is_active(): Boolean
-
Returns true when the timer is currently active.
Starting/stopping
function start()
-
Starts the timer (does nothing if it is already started).
function stop()
-
Stops the timer (does nothing if it is already stopped).
function restart()
-
Restarts the timer (can be also called for starting the timer).
Timer handler
virtual function run()
-
Override to handle the timer. The default implementation handles calling of
the callback if it was provided.
Time source
static function get_time(): Integer
static function get_micro_time(): Integer
-
Returns the time in milliseconds or microseconds from an arbitrary start. You have
to use wrapping arithmetic to use (eg. by using the
sub32
intrinsic function
to get the difference). The time source is the same used by the Timer class and
can differ from the other sources.