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.
require_word asks the user to type a word before the confirm button
works, for actions that cannot be undone.
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.
Sourcepub fn require_word(self, word: impl Into<String>) -> Self
pub fn require_word(self, word: impl Into<String>) -> Self
Asks the user to type word before confirming, for an action that cannot be undone, such
as emptying the trash for good: the dialog gains a line “Type word to confirm”
(quvyta.confirm.type-word, with the word in the title tone among secondary text)
and a text field below the message.
The field has focus when the dialog opens and each question starts with it empty. The
confirm button is disabled, drawn in the disabled tone and passed over by Tab, until the
typed text matches the word; then it takes its danger or primary tone and Enter in the
field confirms too. Before that Enter does nothing and the dialog stays. Esc and the close
mark still cancel, and Tab and Shift+Tab visit the field, Cancel, the
alternative and the confirm button in that order.
Only the confirm button waits for the word: an alternative is a different, safe way out and works at once.
Matching ignores spaces around the text and case, the Turkish way included: İ, I, ı
and i are all the same letter, so “sil”, “SİL”, “SIL” and “ Sil “ all match “SİL”, and
“iptal” matches “İPTAL”. Typing the word is meant as a deliberate act, not a secret, so a
keyboard’s idea of the dotted and dotless i never stands in the way. A blank word asks for
nothing and leaves the dialog as it is without this option.
Keep it for what cannot be undone; a question that always asks for typing teaches people to type without reading.
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