pub struct Input { /* private fields */ }Expand description
A text input widget with cursor, selection, clipboard, and undo/redo support
All cursor positions are character-based (not byte-based) to properly handle UTF-8 multi-byte characters like emoji and CJK characters.
Implementations§
Source§impl Input
impl Input
Sourcepub fn placeholder(self, text: impl Into<String>) -> Self
pub fn placeholder(self, text: impl Into<String>) -> Self
Set placeholder text
Sourcepub fn cursor_style(self, fg: Color, bg: Color) -> Self
pub fn cursor_style(self, fg: Color, bg: Color) -> Self
Set cursor colors
Sourcepub fn selection_bg(self, color: Color) -> Self
pub fn selection_bg(self, color: Color) -> Self
Set selection background color
Sourcepub fn selection(&self) -> Option<(usize, usize)>
pub fn selection(&self) -> Option<(usize, usize)>
Get selection range (start, end) if there is a selection
Sourcepub fn selected_text(&self) -> Option<&str>
pub fn selected_text(&self) -> Option<&str>
Get selected text
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Check if there’s an active selection
Sourcepub fn start_selection(&mut self)
pub fn start_selection(&mut self)
Start selection at current cursor position
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear selection
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all text
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear undo/redo history
Sourcepub fn handle_key_event(&mut self, event: &KeyEvent) -> bool
pub fn handle_key_event(&mut self, event: &KeyEvent) -> bool
Handle key event with modifiers, returns true if needs redraw
Sourcepub fn handle_key(&mut self, key: &Key) -> bool
pub fn handle_key(&mut self, key: &Key) -> bool
Handle key input (without modifiers), returns true if value changed
Trait Implementations§
Source§impl StyledView for Input
impl StyledView for Input
Source§fn remove_class(&mut self, class: &str)
fn remove_class(&mut self, class: &str)
Remove a CSS class
Source§fn toggle_class(&mut self, class: &str)
fn toggle_class(&mut self, class: &str)
Toggle a CSS class
Auto Trait Implementations§
impl Freeze for Input
impl RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl UnwindSafe for Input
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().