pub fn simple_message<'a>(title: &'a str, content: &'a str) -> MessageChoiceExpand 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?
More examples
examples/message_bank.rs (line 50)
24 fn add_message(&self) {
25 let title = self.message_title.text();
26 let content = self.message_content.text();
27
28 let mut new_button = Default::default();
29 nwg::Button::builder()
30 .text(&title)
31 .parent(&self.window)
32 .build(&mut new_button)
33 .expect("Failed to build button");
34
35 let mut buttons = self.buttons.borrow_mut();
36 let mut handlers = self.handlers.borrow_mut();
37
38 let blen = buttons.len() as u32;
39 let (x, y) = (blen % 6, blen / 6);
40 self.layout.add_child(x, y + 1, &new_button);
41
42 // You can share controls handle with events handlers
43 let new_button_handle = new_button.handle;
44 let handler = nwg::bind_event_handler(
45 &new_button.handle,
46 &self.window.handle,
47 move |evt, _evt_data, handle| 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 }