Skip to main content

InputNodeState

Struct InputNodeState 

Source
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.

Source

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 when value is 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 - Constructed InputNodeState with no active selection.
Source

pub fn set_value(&mut self, value: String) -> &mut Self

Replaces the input value while preserving mid-string caret offsets (snapped to UTF-8 boundaries), advancing end-aligned carets, and clearing stale selections.

§Arguments
  • &Self - Mutable input state.
  • String - Replacement UTF-8 input value.
§Returns
  • &mut Self - Mutable reference for fluent chaining.
Source

pub fn text<S>(value: S) -> Self
where S: Into<String>,

Creates an enabled single-line InputNodeState initialized with value and caret at the end.

§Arguments
  • S - Initial input text value.
§Returns
  • Self - Ready InputNodeState.
Source

pub fn with_placeholder<S>(self, placeholder: S) -> Self
where S: Into<String>,

Sets placeholder text displayed when the input value is empty.

§Arguments
  • Self - Source input state.
  • S - Placeholder text.
§Returns
  • Self - Updated input state.
Source

pub fn with_password(self, password: bool) -> Self

Toggles masked password rendering.

§Arguments
  • Self - Source input state.
  • bool - Password mode flag.
§Returns
  • Self - Updated input state.
Source

pub fn with_multiline(self, multiline: bool) -> Self

Toggles multi-line text editing.

§Arguments
  • Self - Source input state.
  • bool - Multiline flag.
§Returns
  • Self - Updated input state.
Source

pub fn with_disabled(self, disabled: bool) -> Self

Toggles disabled state preventing user edits.

§Arguments
  • Self - Source input state.
  • bool - Disabled flag.
§Returns
  • Self - Updated input state.
Source

pub fn clamp_caret(&mut self)

Clamps caret and selection_anchor to valid UTF-8 char boundaries inside value.

§Arguments
  • &Self - Mutable input state.
Source

pub fn clamped_caret_byte(&self) -> usize

Returns the clamped UTF-8 byte offset of the caret inside value.

§Arguments
  • &Self - Input state reference.
§Returns
  • usize - Valid UTF-8 char boundary byte offset in 0..=value.len().
Source

pub fn caret_char_index(&self) -> usize

Returns the 0-based Unicode scalar character index of the caret inside value.

§Arguments
  • &Self - Input state reference.
§Returns
  • usize - Caret character index in 0..=value.chars().count().
Source

pub fn selection_byte_range(&self) -> Option<(usize, usize)>

Returns the sorted (start_byte, end_byte) range of the active selection, or None when collapsed.

§Arguments
  • &Self - Input state reference.
§Returns
  • Option<(usize, usize)> - Sorted valid UTF-8 byte bounds (start, end) with start < end.
Source

pub fn selection_char_range(&self) -> Option<(usize, usize)>

Returns the sorted (start_char, end_char) Unicode scalar range of the active selection, or None when collapsed.

§Arguments
  • &Self - Input state reference.
§Returns
  • Option<(usize, usize)> - Sorted character bounds (start_char, end_char) with start_char < end_char.
Source

pub fn selected_text(&self) -> Option<&str>

Returns the currently selected UTF-8 slice (or None when empty or password-masked).

§Arguments
  • &Self - Input state reference.
§Returns
  • Option<&str> - Selected UTF-8 text slice safe to copy to the clipboard.
Source

pub fn caret_prefix_for_display<'a>(&self, rendered_text: &'a str) -> &'a str

Returns the slice of rendered_text preceding the caret for DrawCommand::TextCaret glyph measurement.

§Arguments
  • &Self - Input state reference.
  • &'a str - Displayed text (value, or masked "***" for password inputs).
§Returns
  • &'a str - UTF-8 prefix slice ending at the caret position.
Source

pub fn clear_selection(&mut self) -> bool

Collapses any active selection without moving the caret.

§Arguments
  • &Self - Mutable input state.
§Returns
  • bool - true if a non-empty selection was cleared.
Source

pub fn select_all(&mut self) -> bool

Selects the entire input text value and moves the caret to the end.

§Arguments
  • &Self - Mutable input state.
§Returns
  • bool - true when non-empty text was selected.
Source

pub fn delete_selection(&mut self) -> bool

Deletes the active selection range if present and collapses the caret to its start.

§Arguments
  • &Self - Mutable input state.
§Returns
  • bool - true when text was deleted.
Source

pub fn cut_selected(&mut self) -> Option<String>

Cuts the active selection, returning the copied text (when non-password) and deleting it from value.

§Arguments
  • &Self - Mutable input state.
§Returns
  • Option<String> - Cut UTF-8 text if a copyable selection was active.
Source

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 in 0..=value.chars().count().
  • bool - When true, extends the active selection to char_idx.
Source

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 - When true, jumps to the previous word boundary.
  • bool - When true, jumps to the start of the current line.
  • bool - When true, extends the active selection.
Source

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 - When true, jumps to the next word boundary.
  • bool - When true, jumps to the end of the current line.
  • bool - When true, extends the active selection.
Source

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 - When true, jumps to byte 0 across all lines.
  • bool - When true, extends the active selection.
Source

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 - When true, jumps to value.len() across all lines.
  • bool - When true, extends the active selection.
Source

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 - When true, extends the active selection.
Source

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 - When true, extends the active selection.
Source

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.
Source

pub fn backspace(&mut self)

Removes the active selection or the single Unicode scalar immediately preceding the caret.

§Arguments
  • &Self - Mutable input state.
Source

pub fn backspace_word(&mut self)

Removes the active selection or the word immediately preceding the caret.

§Arguments
  • &Self - Mutable input state.
Source

pub fn delete_forward(&mut self)

Removes the active selection or the single Unicode scalar immediately following the caret.

§Arguments
  • &Self - Mutable input state.
Source

pub fn delete_word_forward(&mut self)

Removes the active selection or the word immediately following the caret.

§Arguments
  • &Self - Mutable input state.
Source§

impl InputNodeState

Source

pub fn get_value(&self) -> &String

Source

pub fn get_mut_value(&mut self) -> &mut String

Source

pub fn get_placeholder(&self) -> &String

Source

pub fn get_mut_placeholder(&mut self) -> &mut String

Source

pub fn set_placeholder(&mut self, val: String) -> &mut Self

Source

pub fn get_caret(&self) -> usize

Source

pub fn get_mut_caret(&mut self) -> &mut usize

Source

pub fn set_caret(&mut self, val: usize) -> &mut Self

Source

pub fn get_selection_anchor(&self) -> Option<usize>

Source

pub fn try_get_selection_anchor(&self) -> Option<usize>

Source

pub fn get_mut_selection_anchor(&mut self) -> &mut Option<usize>

Source

pub fn set_selection_anchor(&mut self, val: Option<usize>) -> &mut Self

Source

pub fn get_password(&self) -> bool

Source

pub fn get_mut_password(&mut self) -> &mut bool

Source

pub fn set_password(&mut self, val: bool) -> &mut Self

Source

pub fn get_multiline(&self) -> bool

Source

pub fn get_mut_multiline(&mut self) -> &mut bool

Source

pub fn set_multiline(&mut self, val: bool) -> &mut Self

Source

pub fn get_disabled(&self) -> bool

Source

pub fn get_mut_disabled(&mut self) -> &mut bool

Source

pub fn set_disabled(&mut self, val: bool) -> &mut Self

Trait Implementations§

Source§

impl Clone for InputNodeState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InputNodeState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InputNodeState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for InputNodeState

Source§

impl PartialEq for InputNodeState

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for InputNodeState

Auto Trait Implementations§

§

impl Forget for InputNodeState

§

impl Freeze for InputNodeState
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for InputNodeState

§

impl RefUnwindSafe for InputNodeState

§

impl Send for InputNodeState
where RawVecInner: Send,

§

impl Sync for InputNodeState
where RawVecInner: Sync,

§

impl Unpin for InputNodeState
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for InputNodeState

§

impl UnwindSafe for InputNodeState
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.