pub struct Confirm<Msg> { /* private fields */ }Expand description
A question for Command::confirm: a title, an optional message,
and the messages for the answers.
The dialog has two buttons, Cancel and the confirm button, labelled from
quvyta.confirm.cancel and quvyta.confirm.confirm unless given. Cancel has focus. The
question is dismissable by default: Esc and the close mark × at the top right cancel, always
together; dismissable(false) turns both off so only the buttons
answer. A click on the dimmed screen never answers, so a stray click is harmless.
alternative adds a third way between the two, such as “Save ·
Continue · Discard” for recovered work. The buttons then read Cancel, the alternative and the
confirm button from left to right, Tab and Shift+Tab visit them in that order, and Cancel
still has focus when the dialog opens; Esc and the close mark still cancel.
Implementations§
Source§impl<Msg> Confirm<Msg>
impl<Msg> Confirm<Msg>
Sourcepub fn new(title: impl Into<String>, on_confirm: Msg) -> Self
pub fn new(title: impl Into<String>, on_confirm: Msg) -> Self
Asks title; confirming sends on_confirm.
Sourcepub fn message(self, message: impl Into<String>) -> Self
pub fn message(self, message: impl Into<String>) -> Self
Explains the consequences below the title.
Sourcepub fn danger(self) -> Self
pub fn danger(self) -> Self
Marks the question as destructive: a danger pillar down the dialog’s left edge and a danger confirm button.
Sourcepub fn dismissable(self, dismissable: bool) -> Self
pub fn dismissable(self, dismissable: bool) -> Self
Whether Esc and the close mark cancel the question; true by default. With false
neither works, the mark is not drawn and only the buttons answer.
Sourcepub fn confirm_label(self, label: impl Into<String>) -> Self
pub fn confirm_label(self, label: impl Into<String>) -> Self
The confirm button’s label, e.g. the action’s own verb: “Remove”.
Sourcepub fn cancel_label(self, label: impl Into<String>) -> Self
pub fn cancel_label(self, label: impl Into<String>) -> Self
The cancel button’s label.
Sourcepub fn on_cancel(self, message: Msg) -> Self
pub fn on_cancel(self, message: Msg) -> Self
The message sent when the question is cancelled; without it cancelling only closes the dialog.
Sourcepub fn alternative(self, label: impl Into<String>, message: Msg) -> Self
pub fn alternative(self, label: impl Into<String>, message: Msg) -> Self
A third answer between Cancel and the confirm button: a button labelled label that sends
message, such as “Continue” beside “Discard” and “Save”. Without it the dialog has its
two buttons exactly as before.
Auto Trait Implementations§
impl<Msg> Freeze for Confirm<Msg>
impl<Msg> RefUnwindSafe for Confirm<Msg>
impl<Msg> Send for Confirm<Msg>
impl<Msg> Sync for Confirm<Msg>
impl<Msg> Unpin for Confirm<Msg>
impl<Msg> UnsafeUnpin for Confirm<Msg>
impl<Msg> UnwindSafe for Confirm<Msg>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more