pub struct InputDialog { /* private fields */ }Expand description
A single-field input modal.
Implementations§
Source§impl InputDialog
impl InputDialog
Sourcepub fn new(title: impl Into<LocalizedString>) -> Self
pub fn new(title: impl Into<LocalizedString>) -> Self
Construct a new input dialog with the given title.
Sourcepub fn prompt(self, text: impl Into<LocalizedString>) -> Self
pub fn prompt(self, text: impl Into<LocalizedString>) -> Self
Prompt rendered above the input field. Optional but recommended.
Sourcepub fn placeholder(self, text: impl Into<LocalizedString>) -> Self
pub fn placeholder(self, text: impl Into<LocalizedString>) -> Self
Placeholder shown when the field is empty.
Sourcepub fn default_text(self, text: impl Into<String>) -> Self
pub fn default_text(self, text: impl Into<String>) -> Self
Initial value pre-filled into the field.
Sourcepub fn ok_label(self, label: impl Into<LocalizedString>) -> Self
pub fn ok_label(self, label: impl Into<LocalizedString>) -> Self
Override the OK button label (defaults to the framework’s translated “OK” string).
Sourcepub fn cancel_label(self, label: impl Into<LocalizedString>) -> Self
pub fn cancel_label(self, label: impl Into<LocalizedString>) -> Self
Override the Cancel button label (defaults to the framework’s translated “Cancel” string).
Sourcepub fn on_result(
self,
f: impl Fn(Option<String>, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_result( self, f: impl Fn(Option<String>, &mut EventContext<'_>) + 'static, ) -> Self
Result callback. Invoked exactly once when the user accepts
(Some(value)) or cancels (None).
Sourcepub fn validate(self, f: impl Fn(&str) -> ValidateResult + 'static) -> Self
pub fn validate(self, f: impl Fn(&str) -> ValidateResult + 'static) -> Self
Install a live validator, run on every keystroke.
While it returns Err, the OK button is disabled and Enter does nothing, so
on_result is only ever called with a value the validator
accepted (or with None, for Cancel). Err(Some(msg)) shows msg under the
field; Err(None) blocks without saying anything.
The message is withheld until the field has been edited, so a validator that rejects the empty string does not greet the writer with an error on a dialog they have not yet typed into. The disabled OK is what communicates “not yet” there.
Distinct from TextInput::validator,
which fires on commit and cannot gate a dialog’s accept path.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for InputDialog
impl !Send for InputDialog
impl !Sync for InputDialog
impl !UnwindSafe for InputDialog
impl Freeze for InputDialog
impl Unpin for InputDialog
impl UnsafeUnpin for InputDialog
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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> ErasedDestructor for Twhere
T: 'static,
§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