Skip to main content

TextInputHost

Trait TextInputHost 

Source
pub trait TextInputHost {
    // Required methods
    fn set_client(&self, configuration: &TextInputConfiguration);
    fn show(&self);
    fn update_config(&self, configuration: &TextInputConfiguration);
    fn clear_client(&self);
    fn hide(&self);
    fn set_editing_state(&self, value: &TextEditingValue);
    fn set_composing_rect(&self, rect: Rect);
    fn set_caret_rect(&self, rect: Rect);
    fn set_client_geometry(&self, size: Size, transform: &Matrix4);

    // Provided methods
    fn set_selection_rects(&self, selection_rects: &[SelectionRect]) { ... }
    fn handles_editing_keys(&self) -> bool { ... }
    fn provides_edit_commands(&self) -> bool { ... }
}
Expand description

The host side of Flutter’s text input connection for one view: the calls Flutter’s framework sends its engine on the flutter/textinput channel, one method each.

A client is one text field’s connection: set_client starts a new one, which a host whose input method keeps state by the field it edits, as UIKit does, gives a field of its own; update_config changes the current one’s configuration.

Required Methods§

Source

fn set_client(&self, configuration: &TextInputConfiguration)

Flutter TextInput.setClient: a new client, configured with configuration, has the connection from now on. The keyboard shows only at show.

Source

fn show(&self)

Flutter TextInput.show: the input method shows for the current client.

Source

fn update_config(&self, configuration: &TextInputConfiguration)

Flutter TextInput.updateConfig: the current client’s configuration changed.

Source

fn clear_client(&self)

Flutter TextInput.clearClient: the current client gave the connection up. The keyboard stays until hide, so a field taking the connection next keeps it up.

Source

fn hide(&self)

Flutter TextInput.hide: the input method goes.

Source

fn set_editing_state(&self, value: &TextEditingValue)

Flutter TextInputConnection.setEditingState.

Source

fn set_composing_rect(&self, rect: Rect)

Flutter TextInput.setComposingRect.

Source

fn set_caret_rect(&self, rect: Rect)

Flutter TextInput.setCaretRect.

Source

fn set_client_geometry(&self, size: Size, transform: &Matrix4)

Flutter TextInput.setEditableSizeAndTransform.

Provided Methods§

Source

fn set_selection_rects(&self, selection_rects: &[SelectionRect])

Flutter TextInput.setSelectionRects: the bounds of each grapheme of the field’s text in sight, in the field’s coordinates, which set_client_geometry takes to the view’s. Flutter’s framework sends them on iOS alone, while stylus handwriting is enabled, for the system’s text input to place its caret, its candidates and its menus.

The default drops them, for a host whose input methods take no geometry beyond the caret.

Source

fn handles_editing_keys(&self) -> bool

Whether this text input turns editing keys into edits before the framework sees them: backspace and delete, caret movement, the line and document ends.

Flutter has no such question because each of its embedders is written for one host: its macOS and iOS embedders do interpret those keys, and its text field bindings for those platforms step aside so a key is not acted on twice.

Defaults to false, which is what a host built on a windowing library that reports plain key presses should answer, whichever platform it runs on. A host that hands the framework the operating system’s own editing commands answers true, and the field then leaves those keys to it.

Source

fn provides_edit_commands(&self) -> bool

Whether the host sends the view Edit’s commands as events through a command of its own, which the user’s ⌘C, ⌘X and ⌘V reach once the framework leaves them unhandled: macOS’s Edit menu, or the host’s of a program that runs inside another app. A text field then leaves those keys unhandled and acts on the clipboard_event the command sends, as Flutter’s text fields on the web leave them to the browser.

Defaults to false: a host whose system has no such command, or whose app may have set a menu bar without Edit’s commands, keeps them in the field.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§