Skip to main content

TextInputController

Struct TextInputController 

Source
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

Source

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. If None, uses 1.2x the font size.
Source

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

pub fn line_height(&self) -> Px

Returns the line height in pixels.

Source

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.

Source

pub fn editor(&self) -> &Editor<'static>

Returns a reference to the underlying glyphon::Editor.

Source

pub fn with_editor_mut<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Editor<'static>) -> R,

Mutates the underlying glyphon::Editor and refreshes layout state.

Source

pub fn selection_color(&self) -> Color

Returns the current selection highlight color.

Source

pub fn set_selection_color(&mut self, color: Color)

Sets the selection highlight color.

§Arguments
  • color - The new selection color.
Source

pub fn text_color(&self) -> Color

Returns the current text color.

Source

pub fn set_text_color(&mut self, color: Color)

Sets the text color used by the editor.

Source

pub fn text_style(&self) -> TextStyle

Returns the typography used by editable text.

Source

pub fn set_text_style(&mut self, style: TextStyle)

Sets typography while preserving text and selection.

Source

pub fn cursor_color(&self) -> Color

Returns the cursor color.

Source

pub fn set_cursor_color(&mut self, color: Color)

Sets the cursor color used by the editor.

Source

pub fn set_display_transform(&mut self, transform: Option<DisplayTransform>)

Sets a display transform applied when rendering text.

Source

pub fn display_transform_active(&self) -> bool

Returns whether a display transform is active.

Source

pub fn is_dragging(&self) -> bool

Returns true if a drag operation is in progress.

Source

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.

Source

pub fn set_text(&mut self, text: &str)

Sets the entire text content of the editor, preserving cursor position as much as possible.

§Arguments
  • text - The new text content to set in the editor.
Source

pub fn text(&self) -> String

Returns the current text content.

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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 T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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<T> for T

§

fn downcast(&self) -> &T

§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

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

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> SendSync for T
where T: Send + Sync + 'static,

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more