Skip to main content

modal_info_message

Function modal_info_message 

Source
pub fn modal_info_message<'a, P: Into<ControlHandle>>(
    parent: P,
    title: &'a str,
    content: &'a str,
) -> MessageChoice
Expand description

Display a simple message box. The message box has for style MessageButtons::Ok and MessageIcons::Info.

This functions panics if a non window control is used as parent (ex: a menu)

Parameters:

  • parent: Parent window to lock for the duration of the message box
  • title: The message box title
  • content: The message box message
Examples found in repository?
examples/system_tray.rs (line 27)
26    fn hello1(&self) {
27        nwg::modal_info_message(&self.window, "Hello", "Hello World!");
28    }
More examples
Hide additional examples
examples/basic.rs (lines 18-22)
17    fn say_hello(&self) {
18        nwg::modal_info_message(
19            &self.window,
20            "Hello",
21            &format!("Hello {}", self.name_edit.text()),
22        );
23    }
24
25    fn say_goodbye(&self) {
26        nwg::modal_info_message(
27            &self.window,
28            "Goodbye",
29            &format!("Goodbye {}", self.name_edit.text()),
30        );
31        nwg::stop_thread_dispatch();
32    }
examples/basic_layout.rs (lines 19-23)
18    fn say_hello(&self) {
19        nwg::modal_info_message(
20            &self.window,
21            "Hello",
22            &format!("Hello {}", self.name_edit.text()),
23        );
24    }
25
26    fn say_goodbye(&self) {
27        nwg::modal_info_message(
28            &self.window,
29            "Goodbye",
30            &format!("Goodbye {}", self.name_edit.text()),
31        );
32        nwg::stop_thread_dispatch();
33    }
examples/basic_barebone.rs (lines 58-62)
12fn main() {
13    nwg::init().expect("Failed to init Native Windows GUI");
14    nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");
15
16    let mut window = Default::default();
17    let mut name_edit = Default::default();
18    let mut hello_button = Default::default();
19    let layout = Default::default();
20
21    nwg::Window::builder()
22        .size((300, 115))
23        .position((300, 300))
24        .title("Basic example")
25        .build(&mut window)
26        .unwrap();
27
28    nwg::TextInput::builder()
29        .text("Heisenberg")
30        .focus(true)
31        .parent(&window)
32        .build(&mut name_edit)
33        .unwrap();
34
35    nwg::Button::builder()
36        .text("Say my name")
37        .parent(&window)
38        .build(&mut hello_button)
39        .unwrap();
40
41    nwg::GridLayout::builder()
42        .parent(&window)
43        .spacing(1)
44        .child(0, 0, &name_edit)
45        .child_item(nwg::GridLayoutItem::new(&hello_button, 0, 1, 1, 2))
46        .build(&layout)
47        .unwrap();
48
49    let window = Rc::new(window);
50    let events_window = window.clone();
51
52    let handler = nwg::full_bind_event_handler(&window.handle, move |evt, _evt_data, handle| {
53        use nwg::Event as E;
54
55        match evt {
56            E::OnWindowClose => {
57                if &handle == &events_window as &nwg::Window {
58                    nwg::modal_info_message(
59                        &events_window.handle,
60                        "Goodbye",
61                        &format!("Goodbye {}", name_edit.text()),
62                    );
63                    nwg::stop_thread_dispatch();
64                }
65            }
66            E::OnButtonClick => {
67                if &handle == &hello_button {
68                    nwg::modal_info_message(
69                        &events_window.handle,
70                        "Hello",
71                        &format!("Hello {}", name_edit.text()),
72                    );
73                }
74            }
75            _ => {}
76        }
77    });
78
79    nwg::dispatch_thread_events();
80    nwg::unbind_event_handler(&handler);
81}