pub struct TextInputState {
pub value: String,
pub cursor: usize,
pub placeholder: String,
pub max_length: Option<usize>,
}Expand description
State for a single-line text input widget.
Pass a mutable reference to Context::text_input each frame. The widget
handles all keyboard events when focused.
§Example
let mut input = TextInputState::with_placeholder("Type here...");
ui.text_input(&mut input);
println!("{}", input.value);Fields§
§value: StringThe current input text.
cursor: usizeCursor position as a character index into value.
placeholder: StringPlaceholder text shown when value is empty.
max_length: Option<usize>Implementations§
Source§impl TextInputState
impl TextInputState
Sourcepub fn with_placeholder(p: impl Into<String>) -> Self
pub fn with_placeholder(p: impl Into<String>) -> Self
Create a text input with placeholder text shown when the value is empty.
pub fn max_length(self, len: usize) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextInputState
impl RefUnwindSafe for TextInputState
impl Send for TextInputState
impl Sync for TextInputState
impl Unpin for TextInputState
impl UnsafeUnpin for TextInputState
impl UnwindSafe for TextInputState
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