pub struct TextInputController { /* private fields */ }Expand description
State structure for the text input, managing text content, cursor, selection, and editing logic. Core text editing state, shared between components Core state for text editing, including content, selection, cursor, and interaction state.
This struct manages the text buffer, selection, cursor position, focus, and
user interaction state. It is designed to be shared between UI components
via a TextEditorController.
Implementations§
Source§impl TextEditorController
impl TextEditorController
Sourcepub fn new(size: Dp, line_height: Option<Dp>) -> Self
pub fn new(size: Dp, line_height: Option<Dp>) -> Self
Creates a new TextEditorController with the given font size and
optional line height.
§Arguments
size- Font size in Dp.line_height- Optional line height in Dp. IfNone, uses 1.2x the font size.
Sourcepub fn with_selection_color(
size: Dp,
line_height: Option<Dp>,
selection_color: Color,
) -> Self
pub fn with_selection_color( size: Dp, line_height: Option<Dp>, selection_color: Color, ) -> Self
Creates a new TextEditorController with a custom selection highlight
color.
§Arguments
size- Font size in Dp.line_height- Optional line height in Dp.selection_color- Color used for selection highlight.
Sourcepub fn line_height(&self) -> Px
pub fn line_height(&self) -> Px
Returns the line height in pixels.
Sourcepub fn request_focus(&self)
pub fn request_focus(&self)
Requests keyboard focus for this editor while it is attached and available.
Hidden or disabled editors reject the request. A scrollable ancestor may reveal an attached editor that is outside its viewport.
Sourcepub fn editor(&self) -> &Editor<'static>
pub fn editor(&self) -> &Editor<'static>
Returns a reference to the underlying glyphon::Editor.
Sourcepub fn with_editor_mut<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(&mut Editor<'static>) -> R,
pub fn with_editor_mut<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(&mut Editor<'static>) -> R,
Mutates the underlying glyphon::Editor and refreshes layout state.
Sourcepub fn selection_color(&self) -> Color
pub fn selection_color(&self) -> Color
Returns the current selection highlight color.
Sourcepub fn set_selection_color(&mut self, color: Color)
pub fn set_selection_color(&mut self, color: Color)
Sourcepub fn text_color(&self) -> Color
pub fn text_color(&self) -> Color
Returns the current text color.
Sourcepub fn set_text_color(&mut self, color: Color)
pub fn set_text_color(&mut self, color: Color)
Sets the text color used by the editor.
Sourcepub fn text_style(&self) -> TextStyle
pub fn text_style(&self) -> TextStyle
Returns the typography used by editable text.
Sourcepub fn set_text_style(&mut self, style: TextStyle)
pub fn set_text_style(&mut self, style: TextStyle)
Sets typography while preserving text and selection.
Sourcepub fn cursor_color(&self) -> Color
pub fn cursor_color(&self) -> Color
Returns the cursor color.
Sourcepub fn set_cursor_color(&mut self, color: Color)
pub fn set_cursor_color(&mut self, color: Color)
Sets the cursor color used by the editor.
Sourcepub fn set_display_transform(&mut self, transform: Option<DisplayTransform>)
pub fn set_display_transform(&mut self, transform: Option<DisplayTransform>)
Sets a display transform applied when rendering text.
Sourcepub fn display_transform_active(&self) -> bool
pub fn display_transform_active(&self) -> bool
Returns whether a display transform is active.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Returns true if a drag operation is in progress.
Sourcepub fn map_key_event_to_action(
&mut self,
key_event: KeyboardEvent,
key_modifiers: ModifiersState,
) -> Option<Vec<Action>>
pub fn map_key_event_to_action( &mut self, key_event: KeyboardEvent, key_modifiers: ModifiersState, ) -> Option<Vec<Action>>
Map keyboard events to text editing actions Maps a keyboard event to a list of text editing actions for the editor.
This function translates keyboard input (including modifiers) into editing actions such as character insertion, deletion, and navigation.
Clipboard shortcuts are handled at a higher layer so they stay on the unified edit pipeline instead of bypassing controller state.
§Arguments
key_event- The keyboard event to map.key_modifiers- The current keyboard modifier state.
§Returns
An optional vector of glyphon::Action to be applied to the editor.
Auto Trait Implementations§
impl !UnwindSafe for TextEditorController
impl Freeze for TextEditorController
impl RefUnwindSafe for TextEditorController
impl Send for TextEditorController
impl Sync for TextEditorController
impl Unpin for TextEditorController
impl UnsafeUnpin for TextEditorController
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.