PolyMeilex / rfd

Rusty File Dialog
MIT License
526 stars 60 forks source link

Support YesNoCancel for MessageButtons #135

Closed zkldi closed 9 months ago

zkldi commented 10 months ago

I'd like to represent a dialog like this in my application: image

I don't think this is possible currently, as there's no way to have three buttons -- nor distinguish between "No" being clicked and "Cancel".

Is it possible to add support for this? Thanks.

zkldi commented 9 months ago

This is fixed in the newest release of rfd.

Here's some example code incase anyone finds this issue through google:

let choice = rfd::MessageDialog::new()
    .set_title("My App")
    .set_description(format!(
        "Save changes you made?",
    ))
    .set_buttons(rfd::MessageButtons::YesNoCancel)
    .show();

match choice {
    rfd::MessageDialogResult::Yes => {
        // save, close
    },
    rfd::MessageDialogResult::No => {
        // don't save, close.
    }
    rfd::MessageDialogResult::Cancel => {
        // don't close.
    }
    _ => {
        // can't happen.
    }
}