Scribble Text Input Client
Summary
#Adds three methods, showToolbar
, insertTextPlaceholder
, and
removeTextPlaceholder
to the TextInputClient
interface to allow the iOS 14
Scribble feature to insert and remove text placeholders and show the toolbar.
Context
#As of iOS 14, iPads support the Scribble feature when using the Apple Pencil. This feature allows users to use the pencil to interact with text fields to add, delete, select, and modify text.
Description of change
#In native text widgets, the text toolbar is shown when a user uses the pencil
to select text on an iPad running iOS 14 or higher.
To replicate this behavior, the platform sends a textInput
channel message
called TextInputClient.showToolbar
.
This notifies the Dart code that the toolbar should be shown.
When a user holds the pencil down, a visual gap in the text is shown to allow
the user extra space to write.
To replicate this behavior, the platform sends textInput
channel messages
called TextInputClient.insertTextPlaceholder
and
TextInputClient.removeTextPlaceholder
.
Multiline text inputs should have placeholders that provide vertical space,
while single line inputs should provide horizontal space.
Migration guide
#If you previously implemented TextEditingClient
, you must override
showToolbar
, insertTextPlaceholder
, and removeTextPlaceholder
to either
support these Scribble features or provide an empty implementation.
To migrate, implement showToolbar
, insertTextPlaceholder
, and
removeTextPlaceholder
.
Code before migration:
class MyCustomTextInputClient implements TextInputClient {
...
}
Code after migration:
class MyCustomTextInputClient implements TextInputClient {
...
@override
void showToolbar() {
...
}
@override
void insertTextPlaceholder(Size size) {
...
}
@override
void removeTextPlaceholder() {
...
}
}
Timeline
#Landed in version: 2.9.0-1.0.pre
In stable release: 2.10
References
#API documentation:
Relevant issues:
Relevant PRs:
- 24224: Support Scribble Handwriting (engine)
- 75472: Support Scribble Handwriting
- 97437: Re-land Support Scribble Handwriting
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-10-09。 查看文档源码 或者 为本页面内容提出建议。