Skip to main content

Notice

Struct Notice 

Source
pub struct Notice {
    pub handle: ControlHandle,
}
Expand description

An invisible component that can be triggered by other thread.

A notice object does not send data between threads. Rust has already plenty of way to do this. The notice object only serve to “wake up” the GUI thread.

A notice must have a parent window. If the parent is destroyed before the notice, the notice becomes invalid.

Requires the notice feature.

§Example

use native_windows_gui as nwg;
fn build_notice(notice: &mut nwg::Notice, window: &nwg::Window) {
    nwg::Notice::builder()
        .parent(window)
        .build(notice);
}
use native_windows_gui as nwg;
use std::thread;
use std::time;

fn notice(noticer: &nwg::Notice) {
    let sender = noticer.sender();
    
    thread::spawn(move || {
        thread::sleep(time::Duration::new(5, 0));
        sender.notice();
    });
}

Fields§

§handle: ControlHandle

Implementations§

Source§

impl Notice

Source

pub fn builder() -> NoticeBuilder

Source

pub fn create<C: Into<ControlHandle>>(parent: C) -> Result<Notice, NwgError>

A shortcut over the builder API for the notice object

Source

pub fn valid(&self) -> bool

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

Source

pub fn window_handle(&self) -> Option<ControlHandle>

Return an handle to the notice window or None if the window was destroyed.

Source

pub fn set_window_handle<C: Into<ControlHandle>>(&mut self, window: C)

Change the parent window of the notice. This won’t update the NoticeSender already created. Panics if the control is not a window-like control or if the notice was not initialized

Source

pub fn sender(&self) -> NoticeSender

Create a new NoticeSender bound to this Notice

Trait Implementations§

Source§

impl Default for Notice

Source§

fn default() -> Notice

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

impl Drop for Notice

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl From<&Notice> for ControlHandle

Source§

fn from(control: &Notice) -> Self

Converts to this type from the input type.
Source§

impl From<&mut Notice> for ControlHandle

Source§

fn from(control: &mut Notice) -> Self

Converts to this type from the input type.
Source§

impl PartialEq<ControlHandle> for Notice

Source§

fn eq(&self, other: &ControlHandle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Notice> for ControlHandle

Source§

fn eq(&self, other: &Notice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Notice

Source§

fn eq(&self, other: &Notice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Notice

Source§

impl StructuralPartialEq for Notice

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.