pub struct Input<'a, Message> { /* private fields */ }input only.Expand description
A text input builder. Convert it into an Element to render.
An input without an on_input message is rendered disabled.
Implementations§
Source§impl<'a, Message> Input<'a, Message>
impl<'a, Message> Input<'a, Message>
Sourcepub fn id(self, id: impl Into<Id>) -> Self
pub fn id(self, id: impl Into<Id>) -> Self
Sets the widget id, used to focus the input or find it in tests.
Sourcepub fn on_input(self, on_input: impl Fn(String) -> Message + 'a) -> Self
pub fn on_input(self, on_input: impl Fn(String) -> Message + 'a) -> Self
Sets the message produced for every edit. Without it the input is disabled.
pub fn on_input_maybe( self, on_input: Option<impl Fn(String) -> Message + 'a>, ) -> Self
Sourcepub fn on_submit(self, message: Message) -> Self
pub fn on_submit(self, message: Message) -> Self
Sets the message produced when Enter is pressed.
pub fn on_submit_maybe(self, message: Option<Message>) -> Self
Sourcepub fn invalid(self, invalid: bool) -> Self
pub fn invalid(self, invalid: bool) -> Self
Marks the value as invalid, drawing a destructive border.
pub fn size(self, size: Size) -> Self
Sourcepub fn width(self, width: impl Into<Length>) -> Self
pub fn width(self, width: impl Into<Length>) -> Self
Overrides the width. Inputs fill the available width by default.
Sourcepub fn shortcuts(self, shortcuts: Shortcuts) -> Self
pub fn shortcuts(self, shortcuts: Shortcuts) -> Self
Sets which Shortcuts the input handles. All of them by default;
pass Shortcuts::none to turn them all off. The keys of a shortcut
that is off reach the app, and iced’s own editing keys always work.
Sourcepub fn keymap(self, keymap: Keymap<Shortcut>) -> Self
pub fn keymap(self, keymap: Keymap<Shortcut>) -> Self
Replaces the default_keymap, to bind the shortcuts to other keys.
Sourcepub fn clearable(self, message: Message) -> Self
pub fn clearable(self, message: Message) -> Self
Draws an x button at the end of the field while it holds text and is
enabled. Pressing it emits message; the app empties the value.
Sourcepub fn max_length(self, max_length: usize) -> Self
pub fn max_length(self, max_length: usize) -> Self
Stops edits from growing the value past max_length characters.
Typed text that does not fit is dropped and pasted text is cut short.
A longer value set by the app is shown as it is and can only shrink.
pub fn is_enabled(&self) -> bool
Sourcepub fn shows_clear(&self) -> bool
pub fn shows_clear(&self) -> bool
Whether the clear button shows: the input is clearable, enabled and not empty.
Trait Implementations§
Auto Trait Implementations§
impl<'a, Message> !RefUnwindSafe for Input<'a, Message>
impl<'a, Message> !Send for Input<'a, Message>
impl<'a, Message> !Sync for Input<'a, Message>
impl<'a, Message> !UnwindSafe for Input<'a, Message>
impl<'a, Message> Forget for Input<'a, Message>
impl<'a, Message> Freeze for Input<'a, Message>
impl<'a, Message> Move for Input<'a, Message>
impl<'a, Message> Unpin for Input<'a, Message>
impl<'a, Message> UnsafeUnpin for Input<'a, Message>where
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'static str: UnsafeUnpin,
String: UnsafeUnpin,
*const dyn Fn(String) -> Message + 'a is !null: UnsafeUnpin,
PhantomData<dyn Fn(String) -> Message + 'a>: UnsafeUnpin,
Message: UnsafeUnpin,
PhantomData<(Chord, Shortcut)>: UnsafeUnpin,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.