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
impl TextInput
Sourcepub fn current_connection(
self: Handle<Self>,
app: &App,
) -> Option<Handle<TextInputConnection>>
pub fn current_connection( self: Handle<Self>, app: &App, ) -> Option<Handle<TextInputConnection>>
The currently attached connection, if any.
Sourcepub fn ensure_initialized(app: &mut App)
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.
Sourcepub fn debug_reset_id(app: &mut App, to: i32)
pub fn debug_reset_id(app: &mut App, to: i32)
Resets the internal ID counter for testing purposes.
Sourcepub fn attach(
app: &mut App,
client: AnyTextInputClient,
configuration: TextInputConfiguration,
) -> Handle<TextInputConnection>
pub fn attach( app: &mut App, client: AnyTextInputClient, configuration: TextInputConfiguration, ) -> Handle<TextInputConnection>
Begin interacting with the text input control.
Sourcepub fn request_autofill(_app: &mut App)
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, aTextInputClientthat calls this method when focused.
Sourcepub fn finish_autofill_context(_app: &mut App, _should_save: bool)
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.
Sourcepub fn update_editing_value(
self: Handle<Self>,
app: &mut App,
value: TextEditingValue,
)
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).
Sourcepub fn perform_action(
self: Handle<Self>,
app: &mut App,
action: TextInputAction,
)
pub fn perform_action( self: Handle<Self>, app: &mut App, action: TextInputAction, )
Flutter TextInputClient.performAction.
Sourcepub fn connection_closed(self: Handle<Self>, app: &mut App)
pub fn connection_closed(self: Handle<Self>, app: &mut App)
Flutter TextInputClient.onConnectionClosed.