Skip to main content

TextInput

Struct TextInput 

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

An low-level interface to the system’s text input control.

To start interacting with the system’s text input control, call attach to establish a TextInputConnection between the system’s text input control and a TextInputClient. The majority of commands available for interacting with the text input control reside in the returned TextInputConnection.

Dart’s TextInput._instance is instance, the App’s singleton.

Implementations§

Source§

impl TextInput

Source

pub fn instance(app: &mut App) -> Handle<TextInput>

Dart’s TextInput._instance.

Source

pub fn current_connection( self: Handle<Self>, app: &App, ) -> Option<Handle<TextInputConnection>>

The currently attached connection, if any.

Source

pub fn ensure_initialized(app: &mut App)

Ensure that a TextInput instance has been set up so that the platform can handle messages on the text input method channel.

Source

pub fn debug_reset_id(app: &mut App, to: i32)

Resets the internal ID counter for testing purposes.

Source

pub fn attach( app: &mut App, client: AnyTextInputClient, configuration: TextInputConfiguration, ) -> Handle<TextInputConnection>

Begin interacting with the text input control.

Source

pub fn request_autofill(_app: &mut App)

Requests the system autofill UI to appear.

Currently only works on Android. Other platforms do not respond to this message.

See also:

  • EditableText, a TextInputClient that calls this method when focused.
Source

pub fn finish_autofill_context(_app: &mut App, _should_save: bool)

Finishes the current autofill context, and potentially saves the user input for future use if should_save is true.

Typically, this method should be called when the user has finalized their input. For example, in a Form, it’s typically done immediately before or after its content is submitted.

The topmost crate::AutofillScopes also call [finish_autofill_context] automatically when they are disposed.

An autofill context is a collection of input fields that live in the platform’s text input plugin. The platform is encouraged to save the user input stored in the current autofill context before the context is destroyed, when TextInput::finish_autofill_context is called with should_save set to true.

Currently, there can only be at most one autofill context at any given time. When any input field in an autofill group requests autofill (which is done automatically when an autofillable EditableText gains focus), the current autofill context will merge the content of that group into itself. When there isn’t an existing autofill context, one will be created to hold the newly added input fields from the group.

Once added to an autofill context, an input field will stay in the context until the context is destroyed. To prevent leaks, call TextInput::finish_autofill_context to signal the text input plugin that the user has finalized their input in the current autofill context. The platform text input plugin either encourages or discourages the platform from saving the user input based on the value of the should_save parameter. The platform usually shows a “Save for autofill?” prompt for user confirmation.

On many platforms, calling [finish_autofill_context] shows the save user input dialog and disrupts the user’s flow. Ideally the dialog should only be shown no more than once for every screen. Consider removing premature [finish_autofill_context] calls to prevent showing the save user input UI too frequently. However, calling [finish_autofill_context] when there’s no existing autofill context usually does not bring up the save user input UI.

Dart’s default is shouldSave == true.

Source

pub fn update_editing_value( self: Handle<Self>, app: &mut App, value: TextEditingValue, )

Flutter TextInputClient.updateEditingState: the host has a new value.

Does not echo the value back to the host (Flutter excludes _PlatformTextInputControl).

Source

pub fn perform_action( self: Handle<Self>, app: &mut App, action: TextInputAction, )

Flutter TextInputClient.performAction.

Source

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

Flutter TextInputClient.onConnectionClosed.

Trait Implementations§

Source§

impl Default for TextInput

Source§

fn default() -> TextInput

Returns the “default value” for a type. Read more

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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