Skip to main content

TextEditingController

Struct TextEditingController 

Source
pub struct TextEditingController { /* private fields */ }
Expand description

A controller for an editable text field.

Whenever the user modifies the text field with an attached this controller, the text field updates value and the controller notifies its listeners. Listeners can then read the text_value and selection properties to learn what the user has typed or how the selection has been updated.

Similarly, you can modify the text or selection properties, and the listener callbacks will fire.

To change how the text looks, write a second TextEditingControllerLeaf that overrides build_text_span.

The associated functions on this type are the shared bodies of Dart’s TextEditingController; a leaf calls one where Dart writes super.….

Implementations§

Source§

impl TextEditingController

Source

pub fn new(app: &mut App) -> Ref<TextEditingController>

Creates a controller for an editable text field, with no initial selection.

This constructor treats a missing text argument as if it were the empty string.

The initial selection is TextSelection::collapsed(-1, …).

The Ref this answers is the keeper a field holds. A widget that takes the erased controller, as Dart takes a TextEditingController, gets one that shares the count from Retained::erase:

let cell = AppCell::new();
let mut app = cell.borrow_mut();
let controller = TextEditingController::new(&mut app);
let field: TextEditingControllerRef = controller.erase();
assert_eq!(field.text_value(&app), "");
Source

pub fn text( self: Ref<Self>, app: &mut App, text: impl Into<String>, ) -> Ref<Self>

Dart TextEditingController(text:).

Source

pub fn from_value( app: &mut App, value: Option<TextEditingValue>, ) -> Ref<TextEditingController>

Creates a controller for an editable text field from an initial TextEditingValue.

Source

pub fn build_text_span( controller: AnyTextEditingController, app: &App, _context: BuildContext, style: Option<TextStyle>, with_composing: bool, ) -> TextSpan

Source§

impl TextEditingController

Source

pub fn dispose(self: Handle<Self>, app: &mut App)

Discards any resources used by the object; see ChangeNotifierData::dispose.

Trait Implementations§

Source§

impl ChangeNotifier for TextEditingController

Source§

fn change_notifier_data(&self) -> &ChangeNotifierData

Source§

fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData

Source§

fn will_add_listener(self: Handle<Self>, app: &mut App)

Runs before the listener is stored. Dart overrides of addListener that work before super.addListener go here.
Source§

fn did_remove_listener(self: Handle<Self>, app: &mut App)

Runs after the listener is removed. Dart overrides of removeListener that work after super.removeListener go here.
Source§

impl Debug for TextEditingController

Source§

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

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

impl TextEditingControllerLeaf for TextEditingController

Source§

fn text_editing_controller_data( self: Handle<Self>, app: &App, ) -> &TextEditingControllerData

Dart’s TextEditingController fields, held under the field text_editing_controller (text_editing_controller_accessors!).
Source§

fn text_editing_controller_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut TextEditingControllerData

Source§

fn build_text_span( self: Handle<Self>, app: &App, context: BuildContext, style: Option<TextStyle>, with_composing: bool, ) -> TextSpan

Builds TextSpan from current editing value. Read more
Source§

fn text_value(self: Handle<Self>, app: &App) -> &str

Source§

fn set_text(self: Handle<Self>, app: &mut App, new_text: impl Into<String>)

Source§

fn value(self: Handle<Self>, app: &App) -> &TextEditingValue

Source§

fn set_value(self: Handle<Self>, app: &mut App, new_value: TextEditingValue)

Source§

fn selection(self: Handle<Self>, app: &App) -> TextSelection

Source§

fn set_selection( self: Handle<Self>, app: &mut App, new_selection: TextSelection, )

Source§

fn clear(self: Handle<Self>, app: &mut App)

Source§

fn clear_composing(self: Handle<Self>, app: &mut App)

Source§

fn as_controller(self: Handle<Self>) -> AnyTextEditingController

This controller as the erased AnyTextEditingController: what to pass where a Dart API takes a TextEditingController.

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

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

Source§

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

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> ListenableObject for T
where T: ChangeNotifier,

Source§

fn add_listener(self: Handle<T>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<T>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.
Source§

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

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

impl<T> Upcast<T> for T

Source§

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