Struct native_windows_gui::Timer[][src]

pub struct Timer {
    pub handle: ControlHandle,
    // some fields omitted
}
👎 Deprecated since 1.0.11:

Use AnimationTimer instead. The winapi timer does not have a constant tick and will call your single threaded from another thread.

Expand description

WARNING: Use AnimationTimer instead. The winapi timer does not have a constant tick and will call your single threaded from another thread.

A timer is an invisible UI component that trigger the OnTimerTick event at the specified interval. Timers are mosty used to handle animations OR to create a timeout. To sync multithreaded action see the Notice object.

A timer still requires a top level window parent. If the top level window parent is destroyed, the timer becomes invalid.

Note that timer SHOULD NOT be used when a consistent interval is needed. The timer event might be triggered much faster than the interval value. For example, when a user resize a window, Timer OnTimerTick gets triggered each time the window size changes. This is a Windows “feature”, there’s probably nothing I can do to fix that.

Requires the timer feature.

Builder parameters:

  • parent: Required. The timer parent container. Should be a top level window
  • interval: The timer tick interval in millisecond
  • stopped: If the timer should start right away. By default timers starts “stopped(true)”. Be sure to include stopped(false) in your builder if you want the timer to start instantly.

Control events:

  • OnTimerTick: When the timer ticks
use native_windows_gui as nwg;

fn build_timer(parent: &nwg::Window)  {
    let mut timer = Default::default();
    nwg::Timer::builder()
        .parent(parent)
        .interval(100)
        .stopped(false)
        .build(&mut timer);
}

Fields

handle: ControlHandle
👎 Deprecated since 1.0.11:

Use AnimationTimer instead. The winapi timer does not have a constant tick and will call your single threaded from another thread.

Implementations

Checks if the timer is still usable. A timer becomes unusable when the parent window is destroyed. This will also return false if the timer is not initialized.

Returns the interval of the timer, in milliseconds.

Sets the interval of the timer, in milliseconds.

Stops the timer.

Starts the timer. If the timer is already running, this restarts it.

Trait Implementations

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.