pub struct Dialog<Msg: Clone> {
pub title: Option<String>,
pub subtitle: Option<String>,
pub body: Option<Box<Element<Msg>>>,
pub actions: Vec<Element<Msg>>,
pub modal: bool,
pub dismiss_msg: Option<Msg>,
pub cancel_msg: Option<Msg>,
pub max_width: f32,
}Expand description
A centered confirmation dialog with optional title, subtitle, body and action buttons.
Fields§
§title: Option<String>§subtitle: Option<String>§body: Option<Box<Element<Msg>>>User-supplied body element rendered between the subtitle and the action row. Use this for sliders, lists, spinners or any other custom content.
actions: Vec<Element<Msg>>§modal: bool§dismiss_msg: Option<Msg>Optional message dispatched when the user taps the scrim
(strictly outside the card). Always None when Self::modal
is true. Construction panics if both are set together.
cancel_msg: Option<Msg>Optional message dispatched when the user presses Escape
while the dialog is on screen. Wire this to the same message
your “Cancel” action button uses.
max_width: f32Implementations§
Source§impl<Msg: Clone> Dialog<Msg>
impl<Msg: Clone> Dialog<Msg>
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a default modal dialog with no title, subtitle, body, or actions. Build it up with the chained setters.
Sourcepub fn title(self, t: impl Into<String>) -> Self
pub fn title(self, t: impl Into<String>) -> Self
Set the dialog title. Wraps across multiple lines if it does not fit on a single one.
Sourcepub fn subtitle(self, s: impl Into<String>) -> Self
pub fn subtitle(self, s: impl Into<String>) -> Self
Set the dialog subtitle. Wraps across multiple lines if it does not fit on a single one.
Sourcepub fn body(self, e: impl Into<Element<Msg>>) -> Self
pub fn body(self, e: impl Into<Element<Msg>>) -> Self
Replace the dialog body with a custom element — slider, progress indicator, list, anything. Rendered between the subtitle and the action row.
Sourcepub fn action(self, e: impl Into<Element<Msg>>) -> Self
pub fn action(self, e: impl Into<Element<Msg>>) -> Self
Append an action element to the right-aligned action row.
Typically a Button; any
Element is accepted.
Sourcepub fn modal(self, on: bool) -> Self
pub fn modal(self, on: bool) -> Self
Toggle modality. Default: true (every pointer event outside
the card is silently absorbed).
Sourcepub fn dismiss_on_scrim(self, msg: Msg) -> Self
pub fn dismiss_on_scrim(self, msg: Msg) -> Self
Bind a message dispatched when the user taps the scrim
(outside the card). Only valid for non-modal dialogs;
construction panics if combined with modal( true ).
Trait Implementations§
Auto Trait Implementations§
impl<Msg> Freeze for Dialog<Msg>where
Msg: Freeze,
impl<Msg> !RefUnwindSafe for Dialog<Msg>
impl<Msg> !Send for Dialog<Msg>
impl<Msg> !Sync for Dialog<Msg>
impl<Msg> Unpin for Dialog<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for Dialog<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
§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> 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