pub struct Confirm {
pub title: String,
pub detail: String,
pub verb: String,
pub danger: bool,
pub command: CommandId,
pub args: Value,
pub copy: bool,
pub details: Details,
pub secondary: Option<Secondary>,
pub cancel: String,
pub order: Option<ButtonOrder>,
}Expand description
A question before an action: a primary button and Cancel, or, with a
Secondary, the classic three buttons (“Save”, “Don’t save”,
“Cancel”) in the platform’s order (ButtonOrder).
use egui_pop_api::dialogs::{Confirm, Secondary};
use egui_pop_model::ids::CommandId;
let ask = Confirm::new("Quit with unsaved edits?", "Retry saving", CommandId::from_static("doc.save"))
.secondary(Secondary::new("Quit without saving", CommandId::from_static("app.quit")).danger())
.cancel("Keep editing");
assert!(ask.secondary.as_ref().is_some_and(|s| s.danger));Need (dialog): a confirmation dialog. Need (dialog): ask before a destructive action. Need (dialog): a three-button question (Save, Don’t save, Cancel).
Fields§
§title: String§detail: StringThe consequences, in one line.
verb: StringThe primary button: what it does.
danger: boolDestructive: the danger style, the focus starts on Cancel, Enter does not accept.
command: CommandId§args: Value§copy: boolThe Copy button in its bottom corner (on by default).
details: DetailsTechnical lines for a bug report (none by default).
secondary: Option<Secondary>A second action beside the primary one (none by default):
answered as the choice of index 1 ({"answer": "choose", "index": 1}), the primary one being index 0 or an accept.
cancel: StringThe Cancel button’s text: “Cancel”, translated, when empty.
order: Option<ButtonOrder>The buttons’ order: the context’s (ButtonOrder::of, the
platform’s unless pinned) unless given.
Implementations§
Source§impl Confirm
impl Confirm
pub fn new(title: &str, verb: &str, command: CommandId) -> Self
Sourcepub fn secondary(self, secondary: Secondary) -> Self
pub fn secondary(self, secondary: Secondary) -> Self
A second action beside the primary one: three buttons.
Sourcepub fn order(self, order: ButtonOrder) -> Self
pub fn order(self, order: ButtonOrder) -> Self
The buttons in this order rather than the platform’s.
Sourcepub fn details<K: Into<String>, V: Into<String>>(
self,
lines: impl IntoIterator<Item = (K, V)>,
mode: DetailsMode,
) -> Self
pub fn details<K: Into<String>, V: Into<String>>( self, lines: impl IntoIterator<Item = (K, V)>, mode: DetailsMode, ) -> Self
With technical details: key-value lines the Copy button appends to
the copied text, hidden or shown (DetailsMode; hidden by
default on a confirmation).
pub fn detail(self, detail: &str) -> Self
pub fn danger(self) -> Self
pub fn args(self, args: Json) -> Self
Trait Implementations§
Source§impl From<Confirm> for DialogSpec
impl From<Confirm> for DialogSpec
impl StructuralPartialEq for Confirm
Auto Trait Implementations§
impl Freeze for Confirm
impl RefUnwindSafe for Confirm
impl Send for Confirm
impl Sync for Confirm
impl Unpin for Confirm
impl UnsafeUnpin for Confirm
impl UnwindSafe for Confirm
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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