pub struct TextFieldModifierNode { /* private fields */ }Expand description
Modifier node for editable text fields.
This node is the core of BasicTextField, handling:
- Text measurement and layout
- Cursor and selection rendering
- Pointer input for cursor positioning
Implementations§
Source§impl TextFieldModifierNode
impl TextFieldModifierNode
Sourcepub fn new(state: TextFieldState) -> Self
pub fn new(state: TextFieldState) -> Self
Creates a new text field modifier node.
Sourcepub fn with_line_limits(self, line_limits: TextFieldLineLimits) -> Self
pub fn with_line_limits(self, line_limits: TextFieldLineLimits) -> Self
Creates a node with custom line limits.
Sourcepub fn line_limits(&self) -> TextFieldLineLimits
pub fn line_limits(&self) -> TextFieldLineLimits
Returns the current line limits configuration.
Sourcepub fn with_cursor_color(self, color: Color) -> Self
pub fn with_cursor_color(self, color: Color) -> Self
Creates a node with custom cursor color.
Sourcepub fn set_focused(&mut self, focused: bool)
pub fn set_focused(&mut self, focused: bool)
Sets the focus state.
Sourcepub fn is_focused(&self) -> bool
pub fn is_focused(&self) -> bool
Returns whether the field is focused.
Sourcepub fn is_focused_rc(&self) -> Rc<RefCell<bool>>
pub fn is_focused_rc(&self) -> Rc<RefCell<bool>>
Returns the is_focused Rc for closure capture.
Sourcepub fn content_offset_rc(&self) -> Rc<Cell<f32>>
pub fn content_offset_rc(&self) -> Rc<Cell<f32>>
Returns the content_offset Rc for closure capture.
Sourcepub fn content_y_offset_rc(&self) -> Rc<Cell<f32>>
pub fn content_y_offset_rc(&self) -> Rc<Cell<f32>>
Returns the content_y_offset Rc for closure capture.
Sourcepub fn cursor_brush(&self) -> Brush
pub fn cursor_brush(&self) -> Brush
Returns the cursor brush for rendering.
Sourcepub fn selection_brush(&self) -> Brush
pub fn selection_brush(&self) -> Brush
Returns the selection brush for rendering selection highlight.
Sourcepub fn insert_text(&mut self, text: &str)
pub fn insert_text(&mut self, text: &str)
Inserts text at the current cursor position (for paste operations).
Sourcepub fn copy_selection(&self) -> Option<String>
pub fn copy_selection(&self) -> Option<String>
Copies the selected text and returns it (for web copy operation). Returns None if no selection.
Sourcepub fn cut_selection(&mut self) -> Option<String>
pub fn cut_selection(&mut self) -> Option<String>
Cuts the selected text: copies and deletes it. Returns the cut text, or None if no selection.
Sourcepub fn get_state(&self) -> TextFieldState
pub fn get_state(&self) -> TextFieldState
Returns a clone of the text field state for use in draw closures. This allows reading selection at DRAW time rather than LAYOUT time.
Sourcepub fn set_content_offset(&self, offset: f32)
pub fn set_content_offset(&self, offset: f32)
Updates the content offset (padding.left) for accurate click-to-position cursor placement. Called from slices collection where padding is known.
Sourcepub fn set_content_y_offset(&self, offset: f32)
pub fn set_content_y_offset(&self, offset: f32)
Updates the content Y offset (padding.top) for cursor Y positioning. Called from slices collection where padding is known.
Sourcepub fn position_cursor_at_offset(&self, x_offset: f32)
pub fn position_cursor_at_offset(&self, x_offset: f32)
Positions cursor at a given x offset within the text. Uses proper text layout hit testing for accurate proportional font support.