simple_message

Function simple_message 

Source
pub fn simple_message<'a>(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. It is recommended to use modal_info_message because it locks the window that creates the message box. This method may be deprecated in the future

Parameters:

  • title: The message box title
  • content: The message box message
Examples found in repository?
examples/partials.rs (line 60)
59    fn save(&self) {
60        nwg::simple_message("Saved!", "Data saved!");
61    }
More examples
Hide additional examples
examples/message_bank.rs (line 50)
26    fn add_message(&self) {
27        let title = self.message_title.text();
28        let content = self.message_content.text();
29
30        let mut new_button = Default::default();
31        nwg::Button::builder()
32            .text(&title)
33            .parent(&self.window)
34            .build(&mut new_button)
35            .expect("Failed to build button");
36
37        let mut buttons = self.buttons.borrow_mut();
38        let mut handlers = self.handlers.borrow_mut();
39
40        let blen = buttons.len() as u32;
41        let (x, y) = (blen % 6, blen / 6);
42        self.layout.add_child(x, y+1, &new_button);
43
44        // You can share controls handle with events handlers
45        let new_button_handle = new_button.handle;
46        let handler = nwg::bind_event_handler(&new_button.handle, &self.window.handle, move |evt, _evt_data, handle| {
47            match evt {
48                nwg::Event::OnButtonClick => {
49                    if handle == new_button_handle {
50                        nwg::simple_message(&title, &content);
51                    }
52                },
53                _ => {}
54            }
55        });
56
57        buttons.push(new_button);
58        handlers.push(handler);
59    }