Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@gspencergoog
Copy link
Contributor

Description

This (mostly) re-lands #21163, which was reverted in #22321

This switches from using onKeyDown to using dispatchKeyEvent on Android so that keys can be intercepted handled by the framework and not continue to be dispatched to other controls.

It also now intercepts key events sent to InputConnection.sendKeyEvent, as some IMEs do (e.g. the Hacker's Keyboard), and sends them to Flutter.

This fixes the problem where (for example) pressing TAB on a hardware keyboard sends the tab to both the text field and to the focus traversal system.

Note that we still can't intercept all keystrokes given to a soft keyboard, only those which the soft keyboard decides to send to InputConnection.sendKeyEvent, and system keys (like the back button) are only received if the IME doesn't eat them.

Related Issues

Tests

  • Added tests for sending events.

Breaking Change

  • No, no existing tests failed, so this is not a breaking change.

@gspencergoog gspencergoog added the Work in progress (WIP) Not ready (yet) for review! label Nov 6, 2020
@gspencergoog gspencergoog marked this pull request as ready for review November 6, 2020 17:55
@gspencergoog gspencergoog removed the Work in progress (WIP) Not ready (yet) for review! label Nov 6, 2020
Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gspencergoog gspencergoog merged commit 13a624a into flutter:master Nov 6, 2020
@gspencergoog gspencergoog deleted the try_pre_ime branch November 6, 2020 20:45
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 6, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 7, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 7, 2020
chaselatta pushed a commit to chaselatta/engine that referenced this pull request Nov 30, 2020
…Event on Android (flutter#22340)

This (mostly) re-lands flutter#21163, which was reverted in flutter#22321

This switches from using onKeyDown to using dispatchKeyEvent on Android so that keys can be intercepted handled by the framework and not continue to be dispatched to other controls.

It also now intercepts key events sent to InputConnection.sendKeyEvent, as some IMEs do (e.g. the Hacker's Keyboard), and sends them to Flutter.

This fixes the problem where (for example) pressing TAB on a hardware keyboard sends the tab to both the text field and to the focus traversal system.

Note that we still can't intercept all keystrokes given to a soft keyboard, only those which the soft keyboard decides to send to InputConnection.sendKeyEvent, and system keys (like the back button) are only received if the IME doesn't eat them.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: focusing widgets to be able to navigate using a hardware keyboard is impossible

3 participants