pub struct MessageDialog<'a> { /* private fields */ }Expand description
Builds and shows message dialogs.
Implementations§
Source§impl<'a> MessageDialog<'a>
impl<'a> MessageDialog<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/tour.rs (line 4)
3fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
4 MessageDialog::new()
5 .set_title("Result")
6 .set_text(&format!("{}:\n{:#?}", &name, &value))
7 .show_alert()
8 .unwrap();
9}
10
11fn main() {
12 let result = MessageDialog::new()
13 .set_title("Tour")
14 .set_text("Do you want to begin the tour?")
15 .set_type(MessageType::Warning)
16 .show_confirm()
17 .unwrap();
18 if !result {
19 return;
20 }
21 echo("show_confirm", &result);
22
23 let result = FileDialog::new()
24 .set_location("~")
25 .show_open_single_file()
26 .unwrap();
27 echo("show_open_single_file", &result);
28
29 let result = FileDialog::new()
30 .add_filter("Rust Source", &["rs"])
31 .add_filter("Image", &["png", "jpg", "gif"])
32 .show_open_multiple_file()
33 .unwrap();
34 echo("show_open_multiple_file", &result);
35
36 let result = FileDialog::new().show_open_single_dir().unwrap();
37 echo("show_open_single_dir", &result);
38
39 let result = FileDialog::new()
40 .add_filter("Rust Source", &["rs"])
41 .add_filter("Image", &["png", "jpg", "gif"])
42 .show_save_single_file()
43 .unwrap();
44 echo("show_save_single_file", &result);
45
46 MessageDialog::new()
47 .set_title("End")
48 .set_text("That's the end!")
49 .show_alert()
50 .unwrap();
51}Sourcepub fn set_title(self, title: &'a str) -> Self
pub fn set_title(self, title: &'a str) -> Self
Set the title of the dialog.
Examples found in repository?
examples/tour.rs (line 5)
3fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
4 MessageDialog::new()
5 .set_title("Result")
6 .set_text(&format!("{}:\n{:#?}", &name, &value))
7 .show_alert()
8 .unwrap();
9}
10
11fn main() {
12 let result = MessageDialog::new()
13 .set_title("Tour")
14 .set_text("Do you want to begin the tour?")
15 .set_type(MessageType::Warning)
16 .show_confirm()
17 .unwrap();
18 if !result {
19 return;
20 }
21 echo("show_confirm", &result);
22
23 let result = FileDialog::new()
24 .set_location("~")
25 .show_open_single_file()
26 .unwrap();
27 echo("show_open_single_file", &result);
28
29 let result = FileDialog::new()
30 .add_filter("Rust Source", &["rs"])
31 .add_filter("Image", &["png", "jpg", "gif"])
32 .show_open_multiple_file()
33 .unwrap();
34 echo("show_open_multiple_file", &result);
35
36 let result = FileDialog::new().show_open_single_dir().unwrap();
37 echo("show_open_single_dir", &result);
38
39 let result = FileDialog::new()
40 .add_filter("Rust Source", &["rs"])
41 .add_filter("Image", &["png", "jpg", "gif"])
42 .show_save_single_file()
43 .unwrap();
44 echo("show_save_single_file", &result);
45
46 MessageDialog::new()
47 .set_title("End")
48 .set_text("That's the end!")
49 .show_alert()
50 .unwrap();
51}Sourcepub fn set_text(self, text: &'a str) -> Self
pub fn set_text(self, text: &'a str) -> Self
Set the message text of the dialog.
Examples found in repository?
examples/tour.rs (line 6)
3fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
4 MessageDialog::new()
5 .set_title("Result")
6 .set_text(&format!("{}:\n{:#?}", &name, &value))
7 .show_alert()
8 .unwrap();
9}
10
11fn main() {
12 let result = MessageDialog::new()
13 .set_title("Tour")
14 .set_text("Do you want to begin the tour?")
15 .set_type(MessageType::Warning)
16 .show_confirm()
17 .unwrap();
18 if !result {
19 return;
20 }
21 echo("show_confirm", &result);
22
23 let result = FileDialog::new()
24 .set_location("~")
25 .show_open_single_file()
26 .unwrap();
27 echo("show_open_single_file", &result);
28
29 let result = FileDialog::new()
30 .add_filter("Rust Source", &["rs"])
31 .add_filter("Image", &["png", "jpg", "gif"])
32 .show_open_multiple_file()
33 .unwrap();
34 echo("show_open_multiple_file", &result);
35
36 let result = FileDialog::new().show_open_single_dir().unwrap();
37 echo("show_open_single_dir", &result);
38
39 let result = FileDialog::new()
40 .add_filter("Rust Source", &["rs"])
41 .add_filter("Image", &["png", "jpg", "gif"])
42 .show_save_single_file()
43 .unwrap();
44 echo("show_save_single_file", &result);
45
46 MessageDialog::new()
47 .set_title("End")
48 .set_text("That's the end!")
49 .show_alert()
50 .unwrap();
51}Sourcepub fn set_type(self, typ: MessageType) -> Self
pub fn set_type(self, typ: MessageType) -> Self
Set the type of the message. This usually affects the icon shown in the dialog.
Examples found in repository?
examples/tour.rs (line 15)
11fn main() {
12 let result = MessageDialog::new()
13 .set_title("Tour")
14 .set_text("Do you want to begin the tour?")
15 .set_type(MessageType::Warning)
16 .show_confirm()
17 .unwrap();
18 if !result {
19 return;
20 }
21 echo("show_confirm", &result);
22
23 let result = FileDialog::new()
24 .set_location("~")
25 .show_open_single_file()
26 .unwrap();
27 echo("show_open_single_file", &result);
28
29 let result = FileDialog::new()
30 .add_filter("Rust Source", &["rs"])
31 .add_filter("Image", &["png", "jpg", "gif"])
32 .show_open_multiple_file()
33 .unwrap();
34 echo("show_open_multiple_file", &result);
35
36 let result = FileDialog::new().show_open_single_dir().unwrap();
37 echo("show_open_single_dir", &result);
38
39 let result = FileDialog::new()
40 .add_filter("Rust Source", &["rs"])
41 .add_filter("Image", &["png", "jpg", "gif"])
42 .show_save_single_file()
43 .unwrap();
44 echo("show_save_single_file", &result);
45
46 MessageDialog::new()
47 .set_title("End")
48 .set_text("That's the end!")
49 .show_alert()
50 .unwrap();
51}Sourcepub fn set_owner<W: HasRawWindowHandle>(self, window: &W) -> Self
pub fn set_owner<W: HasRawWindowHandle>(self, window: &W) -> Self
Sets the owner of the dialog. On Unix and GNU/Linux, this is a no-op.
Sourcepub unsafe fn set_owner_handle(self, handle: RawWindowHandle) -> Self
pub unsafe fn set_owner_handle(self, handle: RawWindowHandle) -> Self
Sets the owner of the dialog by raw handle. On Unix and GNU/Linux, this is a no-op.
§Safety
It’s the caller’s responsibility that ensuring the handle is valid.
Sourcepub fn reset_owner(self) -> Self
pub fn reset_owner(self) -> Self
Resets the owner of the dialog to nothing.
Sourcepub fn show_alert(self) -> Result<()>
pub fn show_alert(self) -> Result<()>
Shows a dialog that alert users with some message.
Examples found in repository?
examples/tour.rs (line 7)
3fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
4 MessageDialog::new()
5 .set_title("Result")
6 .set_text(&format!("{}:\n{:#?}", &name, &value))
7 .show_alert()
8 .unwrap();
9}
10
11fn main() {
12 let result = MessageDialog::new()
13 .set_title("Tour")
14 .set_text("Do you want to begin the tour?")
15 .set_type(MessageType::Warning)
16 .show_confirm()
17 .unwrap();
18 if !result {
19 return;
20 }
21 echo("show_confirm", &result);
22
23 let result = FileDialog::new()
24 .set_location("~")
25 .show_open_single_file()
26 .unwrap();
27 echo("show_open_single_file", &result);
28
29 let result = FileDialog::new()
30 .add_filter("Rust Source", &["rs"])
31 .add_filter("Image", &["png", "jpg", "gif"])
32 .show_open_multiple_file()
33 .unwrap();
34 echo("show_open_multiple_file", &result);
35
36 let result = FileDialog::new().show_open_single_dir().unwrap();
37 echo("show_open_single_dir", &result);
38
39 let result = FileDialog::new()
40 .add_filter("Rust Source", &["rs"])
41 .add_filter("Image", &["png", "jpg", "gif"])
42 .show_save_single_file()
43 .unwrap();
44 echo("show_save_single_file", &result);
45
46 MessageDialog::new()
47 .set_title("End")
48 .set_text("That's the end!")
49 .show_alert()
50 .unwrap();
51}Sourcepub fn show_confirm(self) -> Result<bool>
pub fn show_confirm(self) -> Result<bool>
Shows a dialog that let users to choose Yes/No.
Examples found in repository?
examples/tour.rs (line 16)
11fn main() {
12 let result = MessageDialog::new()
13 .set_title("Tour")
14 .set_text("Do you want to begin the tour?")
15 .set_type(MessageType::Warning)
16 .show_confirm()
17 .unwrap();
18 if !result {
19 return;
20 }
21 echo("show_confirm", &result);
22
23 let result = FileDialog::new()
24 .set_location("~")
25 .show_open_single_file()
26 .unwrap();
27 echo("show_open_single_file", &result);
28
29 let result = FileDialog::new()
30 .add_filter("Rust Source", &["rs"])
31 .add_filter("Image", &["png", "jpg", "gif"])
32 .show_open_multiple_file()
33 .unwrap();
34 echo("show_open_multiple_file", &result);
35
36 let result = FileDialog::new().show_open_single_dir().unwrap();
37 echo("show_open_single_dir", &result);
38
39 let result = FileDialog::new()
40 .add_filter("Rust Source", &["rs"])
41 .add_filter("Image", &["png", "jpg", "gif"])
42 .show_save_single_file()
43 .unwrap();
44 echo("show_save_single_file", &result);
45
46 MessageDialog::new()
47 .set_title("End")
48 .set_text("That's the end!")
49 .show_alert()
50 .unwrap();
51}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for MessageDialog<'a>
impl<'a> RefUnwindSafe for MessageDialog<'a>
impl<'a> !Send for MessageDialog<'a>
impl<'a> !Sync for MessageDialog<'a>
impl<'a> Unpin for MessageDialog<'a>
impl<'a> UnwindSafe for MessageDialog<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more