[][src]Struct native_windows_gui::Timer

pub struct Timer {
    pub handle: ControlHandle,
    // some fields omitted
}

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.

Requires the timer feature.

Builder parameters:

  • parent: Required. The button 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

Implementations

impl Timer[src]

pub fn builder() -> TimerBuilder[src]

pub fn valid(&self) -> bool[src]

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.

pub fn interval(&self) -> u32[src]

Returns the interval of the timer, in milliseconds.

pub fn set_interval(&self, i: u32)[src]

Sets the interval of the timer, in milliseconds.

pub fn stop(&self)[src]

Stops the timer.

pub fn start(&self)[src]

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

Trait Implementations

impl Default for Timer[src]

impl Drop for Timer[src]

impl<'_> From<&'_ Timer> for ControlHandle[src]

impl PartialEq<ControlHandle> for Timer[src]

impl PartialEq<Timer> for Timer[src]

impl PartialEq<Timer> for ControlHandle[src]

Auto Trait Implementations

impl !RefUnwindSafe for Timer

impl !Send for Timer

impl !Sync for Timer

impl Unpin for Timer

impl UnwindSafe for Timer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.