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
impl TextEditingController
Sourcepub fn new(app: &mut App) -> Ref<TextEditingController>
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), "");Sourcepub fn text(
self: Ref<Self>,
app: &mut App,
text: impl Into<String>,
) -> Ref<Self>
pub fn text( self: Ref<Self>, app: &mut App, text: impl Into<String>, ) -> Ref<Self>
Dart TextEditingController(text:).
Sourcepub fn from_value(
app: &mut App,
value: Option<TextEditingValue>,
) -> Ref<TextEditingController>
pub fn from_value( app: &mut App, value: Option<TextEditingValue>, ) -> Ref<TextEditingController>
Creates a controller for an editable text field from an initial TextEditingValue.
Sourcepub fn build_text_span(
controller: AnyTextEditingController,
app: &App,
_context: BuildContext,
style: Option<TextStyle>,
with_composing: bool,
) -> TextSpan
pub fn build_text_span( controller: AnyTextEditingController, app: &App, _context: BuildContext, style: Option<TextStyle>, with_composing: bool, ) -> TextSpan
Source§impl TextEditingController
impl TextEditingController
Sourcepub fn dispose(self: Handle<Self>, app: &mut App)
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
impl ChangeNotifier for TextEditingController
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.Source§impl Debug for TextEditingController
impl Debug for TextEditingController
Source§impl TextEditingControllerLeaf for TextEditingController
impl TextEditingControllerLeaf for TextEditingController
Source§fn text_editing_controller_data(
self: Handle<Self>,
app: &App,
) -> &TextEditingControllerData
fn text_editing_controller_data( self: Handle<Self>, app: &App, ) -> &TextEditingControllerData
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
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
fn build_text_span( self: Handle<Self>, app: &App, context: BuildContext, style: Option<TextStyle>, with_composing: bool, ) -> TextSpan
Source§fn set_selection(
self: Handle<Self>,
app: &mut App,
new_selection: TextSelection,
)
fn set_selection( self: Handle<Self>, app: &mut App, new_selection: TextSelection, )
Source§fn clear_composing(self: Handle<Self>, app: &mut App)
fn clear_composing(self: Handle<Self>, app: &mut App)
Source§fn as_controller(self: Handle<Self>) -> AnyTextEditingController
fn as_controller(self: Handle<Self>) -> AnyTextEditingController
AnyTextEditingController: what to pass where a Dart
API takes a TextEditingController.