2.1.47 timer%

► |  | GUI: Racket Graphics Toolkit

1 | Overview
2 | Reference
3 | Configuration
4 | Dynamic Loading
| Bibliography
| Index

► | 2 | Reference

2.1 | Windowing Classes
2.2 | Windowing Functions
2.3 | Drawing Classes
2.4 | Drawing Functions
2.5 | Editor Classes
2.6 | Editor Functions
2.7 | WXME Decoding

▼ | 2.1 | Windowing Classes

2.1.1 | area<%>
2.1.2 | area-container<%>
2.1.3 | area-container-window<%>
2.1.4 | button%
2.1.5 | canvas<%>
2.1.6 | canvas%
2.1.7 | check-box%
2.1.8 | checkable-menu-item%
2.1.9 | choice%
2.1.10 | clipboard-client%
2.1.11 | clipboard<%>
2.1.12 | combo-field%
2.1.13 | control<%>
2.1.14 | control-event%
2.1.15 | cursor%
2.1.16 | dialog%
2.1.17 | event%
2.1.18 | frame%
2.1.19 | gauge%
2.1.20 | group-box-panel%
2.1.21 | grow-box-spacer-pane%
2.1.22 | horizontal-pane%
2.1.23 | horizontal-panel%
2.1.24 | key-event%
2.1.25 | labelled-menu-item<%>
2.1.26 | list-box%
2.1.27 | list-control<%>
2.1.28 | menu%
2.1.29 | menu-bar%
2.1.30 | menu-item<%>
2.1.31 | menu-item%
2.1.32 | menu-item-container<%>
2.1.33 | message%
2.1.34 | mouse-event%
2.1.35 | pane%
2.1.36 | panel%
2.1.37 | popup-menu%
2.1.38 | radio-box%
2.1.39 | selectable-menu-item<%>
2.1.40 | separator-menu-item%
2.1.41 | scroll-event%
2.1.42 | slider%
2.1.43 | subarea<%>
2.1.44 | subwindow<%>
2.1.45 | tab-panel%
2.1.46 | text-field%
2.1.47 | timer%
2.1.48 | top-level-window<%>
2.1.49 | vertical-pane%
2.1.50 | vertical-panel%
2.1.51 | window<%>

On this page:

interval
notify
start
stop

top← prev up next →

timer% : class?
superclass: object%

A timer% object encapsulates an event-based alarm. To use a timer, either instantiate it with a timer-callback thunk to perform the alarm-based action, to derive a new class and override the notify method to perform the alarm-based action. Start a timer with start and stop it with stop. Supplying an initial interval (in milliseconds) when creating a timer also starts the timer.

Timers have a relatively high priority in the event queue. Thus, if the timer delay is set low enough, repeated notification for a timer can preempt user activities (which might be directed at stopping the timer). For timers with relatively short delays, call yield within the notify procedure to allow guaranteed event processing.

See Event Dispatching and Eventspaces for more information about event priorities.

( new timer% | [ | [notify-callback notify-callback] |
|  | [interval interval] |
|  | [just-once? just-once?]]) |

→ ( is-a?/c timer%)
notify-callback : (-> any) = void
interval : ( or/c ( integer-in 0 1000000000) false/c) = #f
just-once? : any/c = #f

The notify-callback thunk is called by the default notify method when the timer expires.

If interval is #f (the default), the timer is not started; in that case, start must be called explicitly. If interval is a number (in milliseconds), then start is called with interval and just-once?.

( send a-timer interval) → ( integer-in 0 1000000000)

Returns the number of milliseconds between each timer expiration (when the timer is running).

( send a-timer notify) → void?

Specification: Called (on an event boundary) when the timer’s alarm expires.

Default implementation: Calls the notify-callback procedure that was provided when the object was created.

( send a-timer start msec [just-once?]) → void?
msec : ( integer-in 0 1000000000)
just-once? : any/c = #f

Starts (or restarts) the timer. If the timer is already running, its alarm time is not changed.

The timer’s alarm expires after msec milliseconds, at which point notify is called (on an event boundary). If just-once? is #f, the timer expires every msec milliseconds until the timer is explicitly stopped. (More precisely, the timer expires msec milliseconds after notify returns each time.) Otherwise, the timer expires only once.

( send a-timer stop) → void?

Stops the timer. A stopped timer never calls notify. If the timer has expired but the call to notify has not yet been dispatched, the call is removed from the event queue.
top← prev up next →