This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Web] Synthesize key events for modifier keys on pointer events. #36724
Merged
auto-submit
merged 4 commits into
flutter:main
from
NevercodeHQ:synthesize_modifier_keys_events_on_pointer_events
Oct 21, 2022
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c727189
Synthesize key events for shift key on pointer events.
bleroux a5c151a
Get the timestamp from the DOM event
bleroux 7bfc20b
Check all modifiers for PointerEvent, MouseEvent and TouchEvent
bleroux 14820cc
Inject KeyboardConverter + add tests
bleroux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Get the timestamp from the DOM event
- Loading branch information
commit a5c151ab0be675a546c254737aeff70cd4fb4070
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,14 +153,15 @@ class KeyboardBinding { | |
| } | ||
|
|
||
| // Synthesize shift key up or down event only when the known pressing state is different. | ||
| void synthesizeShiftKeyIfNeeded(ui.KeyEventType type) { | ||
| void synthesizeShiftKeyIfNeeded(ui.KeyEventType type, num eventTimestamp) { | ||
| // TODO(bleroux): should we take care of shift left AND shift right? | ||
| final int physicalShift = kWebToPhysicalKey['ShiftLeft']!; | ||
| final bool alreadyPressed = _converter._pressingRecords.containsKey(physicalShift); | ||
| final bool synthesizeDown = type == ui.KeyEventType.down && !alreadyPressed; | ||
| final bool synthesizeUp = type == ui.KeyEventType.up && alreadyPressed; | ||
| if (synthesizeDown || synthesizeUp) { | ||
| _converter.performDispatchKeyData(_shiftLeftKeyData(type)); | ||
| final Duration timestamp = _eventTimeStampToDuration(eventTimestamp); | ||
| _converter.performDispatchKeyData(_shiftLeftKeyData(type, timestamp)); | ||
| // Update pressing state | ||
| if (synthesizeDown) { | ||
| _converter._pressingRecords[physicalShift] = _kLogicalShiftLeft; | ||
|
|
@@ -170,9 +171,9 @@ class KeyboardBinding { | |
| } | ||
| } | ||
|
|
||
| ui.KeyData _shiftLeftKeyData(ui.KeyEventType type) { | ||
| ui.KeyData _shiftLeftKeyData(ui.KeyEventType type, Duration timestamp) { | ||
| return ui.KeyData( | ||
| timeStamp: Duration.zero, | ||
| timeStamp: timestamp, | ||
| type: type, | ||
| physical: kWebToPhysicalKey['ShiftLeft']!, | ||
| logical: _kLogicalShiftLeft, | ||
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Let's use a "least event dispatched" strategy:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done