Skip to main content

MessageWindow

Struct MessageWindow 

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

A message only top level window. At least one top level window is required to make a NWG application. See the module documentation

Fields§

§handle: ControlHandle

Implementations§

Source§

impl MessageWindow

Source

pub fn builder() -> MessageWindowBuilder

Examples found in repository?
examples/system_tray.rs (line 70)
61        fn build_ui(mut data: SystemTray) -> Result<SystemTrayUi, nwg::NwgError> {
62            use nwg::Event as E;
63
64            // Resources
65            nwg::Icon::builder()
66                .source_file(Some("./test_rc/cog.ico"))
67                .build(&mut data.icon)?;
68
69            // Controls
70            nwg::MessageWindow::builder().build(&mut data.window)?;
71
72            nwg::TrayNotification::builder()
73                .parent(&data.window)
74                .icon(Some(&data.icon))
75                .tip(Some("Hello"))
76                .build(&mut data.tray)?;
77
78            nwg::Menu::builder()
79                .popup(true)
80                .parent(&data.window)
81                .build(&mut data.tray_menu)?;
82
83            nwg::MenuItem::builder()
84                .text("Hello")
85                .parent(&data.tray_menu)
86                .build(&mut data.tray_item1)?;
87
88            nwg::MenuItem::builder()
89                .text("Popup")
90                .parent(&data.tray_menu)
91                .build(&mut data.tray_item2)?;
92
93            nwg::MenuItem::builder()
94                .text("Exit")
95                .parent(&data.tray_menu)
96                .build(&mut data.tray_item3)?;
97
98            // Wrap-up
99            let ui = SystemTrayUi {
100                inner: Rc::new(data),
101                default_handler: Default::default(),
102            };
103
104            // Events
105            let evt_ui = Rc::downgrade(&ui.inner);
106            let handle_events = move |evt, _evt_data, handle| {
107                if let Some(evt_ui) = evt_ui.upgrade() {
108                    match evt {
109                        E::OnContextMenu => {
110                            if &handle == &evt_ui.tray {
111                                SystemTray::show_menu(&evt_ui);
112                            }
113                        }
114                        E::OnMenuItemSelected => {
115                            if &handle == &evt_ui.tray_item1 {
116                                SystemTray::hello1(&evt_ui);
117                            } else if &handle == &evt_ui.tray_item2 {
118                                SystemTray::hello2(&evt_ui);
119                            } else if &handle == &evt_ui.tray_item3 {
120                                SystemTray::exit(&evt_ui);
121                            }
122                        }
123                        _ => {}
124                    }
125                }
126            };
127
128            ui.default_handler
129                .borrow_mut()
130                .push(nwg::full_bind_event_handler(
131                    &ui.window.handle,
132                    handle_events,
133                ));
134
135            return Ok(ui);
136        }

Trait Implementations§

Source§

impl Default for MessageWindow

Source§

fn default() -> MessageWindow

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

impl Drop for MessageWindow

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 Eq for MessageWindow

Source§

impl From<&MessageWindow> for ControlHandle

Source§

fn from(control: &MessageWindow) -> Self

Converts to this type from the input type.
Source§

impl From<&mut MessageWindow> for ControlHandle

Source§

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

Converts to this type from the input type.
Source§

impl PartialEq for MessageWindow

Source§

fn eq(&self, other: &MessageWindow) -> 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<ControlHandle> for MessageWindow

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<MessageWindow> for ControlHandle

Source§

fn eq(&self, other: &MessageWindow) -> 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 StructuralPartialEq for MessageWindow

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.