[−][src]Struct native_windows_gui::Timer
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 windowinterval
: The timer tick interval in millisecondstopped
: If the timer should start right away. By default timers starts "stopped(true)". Be sure to includestopped(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]
fn eq(&self, other: &ControlHandle) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,