pub struct TextInput<'a> { /* private fields */ }Expand description
A styled single-line text input.
let mut email = String::new();
ui.add(TextInput::new(&mut email).label("Email").hint("you@example.com"));§Ids, focus, and flash state
Flash animations, focus, and cursor state are keyed off the widget’s
egui id. Without id_salt, the id is derived from
egui’s auto-id counter, which is layout-dependent — if a sibling
appears or disappears above this input between frames, the id shifts
and any in-flight flash, focus, or cursor state is lost. Any input
you flash via ResponseFlashExt should pin
its id with id_salt.
Implementations§
Source§impl<'a> TextInput<'a>
impl<'a> TextInput<'a>
Sourcepub fn label(self, text: impl Into<WidgetText>) -> Self
pub fn label(self, text: impl Into<WidgetText>) -> Self
Show a label above the input.
Sourcepub fn hint(self, text: &'a str) -> Self
pub fn hint(self, text: &'a str) -> Self
Show placeholder-style hint text when the field is empty.
Sourcepub fn dirty(self, dirty: bool) -> Self
pub fn dirty(self, dirty: bool) -> Self
Mark the input as having unsaved changes. Shows a sky-coloured accent bar down the left side.
Sourcepub fn desired_width(self, width: f32) -> Self
pub fn desired_width(self, width: f32) -> Self
Desired width (points) for the editor portion of the widget.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TextInput<'a>
impl<'a> RefUnwindSafe for TextInput<'a>
impl<'a> Send for TextInput<'a>
impl<'a> Sync for TextInput<'a>
impl<'a> Unpin for TextInput<'a>
impl<'a> UnsafeUnpin for TextInput<'a>
impl<'a> !UnwindSafe for TextInput<'a>
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
Mutably borrows from an owned value. Read more