Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
6971dcb7
Unverified
Commit
6971dcb7
authored
Aug 15, 2023
by
Tong Mu
Committed by
GitHub
Aug 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explain the keyboard manager protocol (#132533)
Fixes
https://github.com/flutter/flutter/issues/132433
parent
9d942792
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
6 deletions
+34
-6
hardware_keyboard.dart
packages/flutter/lib/src/services/hardware_keyboard.dart
+34
-6
No files found.
packages/flutter/lib/src/services/hardware_keyboard.dart
View file @
6971dcb7
...
@@ -788,14 +788,42 @@ typedef KeyMessageHandler = bool Function(KeyMessage message);
...
@@ -788,14 +788,42 @@ typedef KeyMessageHandler = bool Function(KeyMessage message);
/// and [RawKeyboard] for recording keeping, and then dispatches the [KeyMessage]
/// and [RawKeyboard] for recording keeping, and then dispatches the [KeyMessage]
/// to [keyMessageHandler], the global message handler.
/// to [keyMessageHandler], the global message handler.
///
///
/// [KeyEventManager] also resolves cross-platform compatibility of keyboard
/// implementations. Legacy platforms might have not implemented the new key
/// data API and only send raw key data on each key message. [KeyEventManager]
/// recognize platform types as [KeyDataTransitMode] and dispatches events in
/// different ways accordingly.
///
/// [KeyEventManager] is typically created, owned, and invoked by
/// [KeyEventManager] is typically created, owned, and invoked by
/// [ServicesBinding].
/// [ServicesBinding].
///
/// ## On embedder implementation
///
/// Currently, Flutter has two sets of key event APIs running in parallel.
///
/// * The legacy "raw key event" route receives messages from the
/// "flutter/keyevent" message channel ([SystemChannels.keyEvent]) and
/// dispatches [RawKeyEvent] to [RawKeyboard] and [Focus.onKey] as well as
/// similar methods.
/// * The newer "hardware key event" route receives messages from the
/// "flutter/keydata" message channel (embedder API
/// `FlutterEngineSendKeyEvent`) and dispatches [KeyEvent] to
/// [HardwareKeyboard] and some methods such as [Focus.onKeyEvent].
///
/// [KeyEventManager] resolves cross-platform compatibility of keyboard
/// implementations, since legacy platforms might have not implemented the new
/// key data API and only send raw key data on each key message.
/// [KeyEventManager] recognizes the platform support by detecting whether a
/// message comes from platform channel "flutter/keyevent" before one from
/// "flutter/keydata", or vice versa, at the beginning of the app.
///
/// * If a "flutter/keyevent" message is received first, then this platform is
/// considered a legacy platform. The raw key event is transformed into a
/// hardware key event at best effort. No messages from "flutter/keydata" are
/// expected.
/// * If a "flutter/keydata" message is received first, then this platform is
/// considered a newer platform. The hardware key events are stored, and
/// dispatched only when a raw key message is received.
///
/// Therefore, to correctly implement a platform that supports
/// `FlutterEngineSendKeyEvent`, the platform must ensure that
/// `FlutterEngineSendKeyEvent` is called before sending a message to
/// "flutter/keyevent" at the beginning of the app, and every physical key event
/// is ended with a "flutter/keyevent" message.
class
KeyEventManager
{
class
KeyEventManager
{
/// Create an instance.
/// Create an instance.
///
///
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment