pub struct MessageDialog<'a> { /* private fields */ }
Expand description

Builds and shows message dialogs.

Implementations§

source§

impl<'a> MessageDialog<'a>

source

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();
}
source

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();
}
source

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();
}
source

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();
}
source

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.

source

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.

source

pub fn reset_owner(self) -> Self

Resets the owner of the dialog to nothing.

source

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();
}
source

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§

source§

impl Default for MessageDialog<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.