Struct native_dialog::MessageDialog
source · 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)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
MessageDialog::new()
.set_title("Result")
.set_text(&format!("{}:\n{:#?}", &name, &value))
.show_alert()
.unwrap();
}
fn main() {
let result = MessageDialog::new()
.set_title("Tour")
.set_text("Do you want to begin the tour?")
.set_type(MessageType::Warning)
.show_confirm()
.unwrap();
if !result {
return;
}
echo("show_confirm", &result);
let result = FileDialog::new()
.set_location("~")
.show_open_single_file()
.unwrap();
echo("show_open_single_file", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_open_multiple_file()
.unwrap();
echo("show_open_multiple_file", &result);
let result = FileDialog::new().show_open_single_dir().unwrap();
echo("show_open_single_dir", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_save_single_file()
.unwrap();
echo("show_save_single_file", &result);
MessageDialog::new()
.set_title("End")
.set_text("That's the end!")
.show_alert()
.unwrap();
}
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)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
MessageDialog::new()
.set_title("Result")
.set_text(&format!("{}:\n{:#?}", &name, &value))
.show_alert()
.unwrap();
}
fn main() {
let result = MessageDialog::new()
.set_title("Tour")
.set_text("Do you want to begin the tour?")
.set_type(MessageType::Warning)
.show_confirm()
.unwrap();
if !result {
return;
}
echo("show_confirm", &result);
let result = FileDialog::new()
.set_location("~")
.show_open_single_file()
.unwrap();
echo("show_open_single_file", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_open_multiple_file()
.unwrap();
echo("show_open_multiple_file", &result);
let result = FileDialog::new().show_open_single_dir().unwrap();
echo("show_open_single_dir", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_save_single_file()
.unwrap();
echo("show_save_single_file", &result);
MessageDialog::new()
.set_title("End")
.set_text("That's the end!")
.show_alert()
.unwrap();
}
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)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
MessageDialog::new()
.set_title("Result")
.set_text(&format!("{}:\n{:#?}", &name, &value))
.show_alert()
.unwrap();
}
fn main() {
let result = MessageDialog::new()
.set_title("Tour")
.set_text("Do you want to begin the tour?")
.set_type(MessageType::Warning)
.show_confirm()
.unwrap();
if !result {
return;
}
echo("show_confirm", &result);
let result = FileDialog::new()
.set_location("~")
.show_open_single_file()
.unwrap();
echo("show_open_single_file", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_open_multiple_file()
.unwrap();
echo("show_open_multiple_file", &result);
let result = FileDialog::new().show_open_single_dir().unwrap();
echo("show_open_single_dir", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_save_single_file()
.unwrap();
echo("show_save_single_file", &result);
MessageDialog::new()
.set_title("End")
.set_text("That's the end!")
.show_alert()
.unwrap();
}
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)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn main() {
let result = MessageDialog::new()
.set_title("Tour")
.set_text("Do you want to begin the tour?")
.set_type(MessageType::Warning)
.show_confirm()
.unwrap();
if !result {
return;
}
echo("show_confirm", &result);
let result = FileDialog::new()
.set_location("~")
.show_open_single_file()
.unwrap();
echo("show_open_single_file", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_open_multiple_file()
.unwrap();
echo("show_open_multiple_file", &result);
let result = FileDialog::new().show_open_single_dir().unwrap();
echo("show_open_single_dir", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_save_single_file()
.unwrap();
echo("show_save_single_file", &result);
MessageDialog::new()
.set_title("End")
.set_text("That's the end!")
.show_alert()
.unwrap();
}
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)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
MessageDialog::new()
.set_title("Result")
.set_text(&format!("{}:\n{:#?}", &name, &value))
.show_alert()
.unwrap();
}
fn main() {
let result = MessageDialog::new()
.set_title("Tour")
.set_text("Do you want to begin the tour?")
.set_type(MessageType::Warning)
.show_confirm()
.unwrap();
if !result {
return;
}
echo("show_confirm", &result);
let result = FileDialog::new()
.set_location("~")
.show_open_single_file()
.unwrap();
echo("show_open_single_file", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_open_multiple_file()
.unwrap();
echo("show_open_multiple_file", &result);
let result = FileDialog::new().show_open_single_dir().unwrap();
echo("show_open_single_dir", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_save_single_file()
.unwrap();
echo("show_save_single_file", &result);
MessageDialog::new()
.set_title("End")
.set_text("That's the end!")
.show_alert()
.unwrap();
}
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)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn main() {
let result = MessageDialog::new()
.set_title("Tour")
.set_text("Do you want to begin the tour?")
.set_type(MessageType::Warning)
.show_confirm()
.unwrap();
if !result {
return;
}
echo("show_confirm", &result);
let result = FileDialog::new()
.set_location("~")
.show_open_single_file()
.unwrap();
echo("show_open_single_file", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_open_multiple_file()
.unwrap();
echo("show_open_multiple_file", &result);
let result = FileDialog::new().show_open_single_dir().unwrap();
echo("show_open_single_dir", &result);
let result = FileDialog::new()
.add_filter("Rust Source", &["rs"])
.add_filter("Image", &["png", "jpg", "gif"])
.show_save_single_file()
.unwrap();
echo("show_save_single_file", &result);
MessageDialog::new()
.set_title("End")
.set_text("That's the end!")
.show_alert()
.unwrap();
}
Trait Implementations§
Auto Trait Implementations§
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