pub struct InputNodeState { /* private fields */ }Expand description
Interactive text input state stored on NodeKind::Input.
Implementations§
Source§impl InputNodeState
Text editing and fluent construction helpers for InputNodeState.
impl InputNodeState
Text editing and fluent construction helpers for InputNodeState.
Sourcepub fn new(
value: String,
placeholder: String,
caret: usize,
password: bool,
multiline: bool,
disabled: bool,
) -> Self
pub fn new( value: String, placeholder: String, caret: usize, password: bool, multiline: bool, disabled: bool, ) -> Self
Constructs an InputNodeState with the given text, placeholder, caret byte offset, and flags.
§Arguments
String- Initial UTF-8 input value.String- Placeholder text displayed whenvalueis empty.usize- Initial caret byte offset (snapped to a valid UTF-8 char boundary).bool- Whether characters are masked as a password field.bool- Whether multi-line editing is enabled.bool- Whether user editing is disabled.
§Returns
Self- ConstructedInputNodeStatewith no active selection.
Sourcepub fn with_placeholder<S>(self, placeholder: S) -> Self
pub fn with_placeholder<S>(self, placeholder: S) -> Self
Sourcepub fn with_password(self, password: bool) -> Self
pub fn with_password(self, password: bool) -> Self
Sourcepub fn with_multiline(self, multiline: bool) -> Self
pub fn with_multiline(self, multiline: bool) -> Self
Sourcepub fn with_disabled(self, disabled: bool) -> Self
pub fn with_disabled(self, disabled: bool) -> Self
Sourcepub fn clamp_caret(&mut self)
pub fn clamp_caret(&mut self)
Clamps caret and selection_anchor to valid UTF-8 char boundaries inside value.
§Arguments
&Self- Mutable input state.
Sourcepub fn clamped_caret_byte(&self) -> usize
pub fn clamped_caret_byte(&self) -> usize
Sourcepub fn caret_char_index(&self) -> usize
pub fn caret_char_index(&self) -> usize
Sourcepub fn selection_byte_range(&self) -> Option<(usize, usize)>
pub fn selection_byte_range(&self) -> Option<(usize, usize)>
Sourcepub fn selection_char_range(&self) -> Option<(usize, usize)>
pub fn selection_char_range(&self) -> Option<(usize, usize)>
Sourcepub fn selected_text(&self) -> Option<&str>
pub fn selected_text(&self) -> Option<&str>
Sourcepub fn caret_prefix_for_display<'a>(&self, rendered_text: &'a str) -> &'a str
pub fn caret_prefix_for_display<'a>(&self, rendered_text: &'a str) -> &'a str
Sourcepub fn clear_selection(&mut self) -> bool
pub fn clear_selection(&mut self) -> bool
Sourcepub fn select_all(&mut self) -> bool
pub fn select_all(&mut self) -> bool
Sourcepub fn delete_selection(&mut self) -> bool
pub fn delete_selection(&mut self) -> bool
Sourcepub fn cut_selected(&mut self) -> Option<String>
pub fn cut_selected(&mut self) -> Option<String>
Sourcepub fn set_caret_char_index(&mut self, char_idx: usize, extend_selection: bool)
pub fn set_caret_char_index(&mut self, char_idx: usize, extend_selection: bool)
Places the caret at a 0-based Unicode scalar character index (used for pointer clicks inside an input).
§Arguments
&Self- Mutable input state.usize- Target character index in0..=value.chars().count().bool- Whentrue, extends the active selection tochar_idx.
Sourcepub fn move_left(
&mut self,
word: bool,
to_line_start: bool,
extend_selection: bool,
)
pub fn move_left( &mut self, word: bool, to_line_start: bool, extend_selection: bool, )
Moves the caret left by one char, one word (word), or to line start (to_line_start).
§Arguments
&Self- Mutable input state.bool- Whentrue, jumps to the previous word boundary.bool- Whentrue, jumps to the start of the current line.bool- Whentrue, extends the active selection.
Sourcepub fn move_right(
&mut self,
word: bool,
to_line_end: bool,
extend_selection: bool,
)
pub fn move_right( &mut self, word: bool, to_line_end: bool, extend_selection: bool, )
Moves the caret right by one char, one word (word), or to line end (to_line_end).
§Arguments
&Self- Mutable input state.bool- Whentrue, jumps to the next word boundary.bool- Whentrue, jumps to the end of the current line.bool- Whentrue, extends the active selection.
Sourcepub fn move_home(&mut self, full_start: bool, extend_selection: bool)
pub fn move_home(&mut self, full_start: bool, extend_selection: bool)
Moves the caret to the start of the current line, or to the start of the full text when full_start is true.
§Arguments
&Self- Mutable input state.bool- Whentrue, jumps to byte0across all lines.bool- Whentrue, extends the active selection.
Sourcepub fn move_end(&mut self, full_end: bool, extend_selection: bool)
pub fn move_end(&mut self, full_end: bool, extend_selection: bool)
Moves the caret to the end of the current line, or to the end of the full text when full_end is true.
§Arguments
&Self- Mutable input state.bool- Whentrue, jumps tovalue.len()across all lines.bool- Whentrue, extends the active selection.
Sourcepub fn move_up(&mut self, extend_selection: bool)
pub fn move_up(&mut self, extend_selection: bool)
Moves the caret up one line (preserving column in multiline inputs) or to start in single-line inputs.
§Arguments
&Self- Mutable input state.bool- Whentrue, extends the active selection.
Sourcepub fn move_down(&mut self, extend_selection: bool)
pub fn move_down(&mut self, extend_selection: bool)
Moves the caret down one line (preserving column in multiline inputs) or to end in single-line inputs.
§Arguments
&Self- Mutable input state.bool- Whentrue, extends the active selection.
Sourcepub fn insert_str(&mut self, text: &str)
pub fn insert_str(&mut self, text: &str)
Inserts text at the current caret position (replacing any active selection) and advances the caret.
§Arguments
&Self- Mutable input state.&str- UTF-8 text to insert.
Sourcepub fn backspace(&mut self)
pub fn backspace(&mut self)
Removes the active selection or the single Unicode scalar immediately preceding the caret.
§Arguments
&Self- Mutable input state.
Sourcepub fn backspace_word(&mut self)
pub fn backspace_word(&mut self)
Removes the active selection or the word immediately preceding the caret.
§Arguments
&Self- Mutable input state.
Sourcepub fn delete_forward(&mut self)
pub fn delete_forward(&mut self)
Removes the active selection or the single Unicode scalar immediately following the caret.
§Arguments
&Self- Mutable input state.
Sourcepub fn delete_word_forward(&mut self)
pub fn delete_word_forward(&mut self)
Removes the active selection or the word immediately following the caret.
§Arguments
&Self- Mutable input state.