mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
MacOS: Do not send key event if modifiers flags haven't changed (flutter/engine#26347)
* MacOS: Do not send key event if modifiers flags haven't changed Fixes https://github.com/flutter/flutter/issues/77535 * Extend unit test * Comment typo
This commit is contained in:
parent
7bb9bed259
commit
46516e5327
@ -50,8 +50,12 @@
|
||||
case NSEventTypeFlagsChanged:
|
||||
if (event.modifierFlags < _previouslyPressedFlags) {
|
||||
type = @"keyup";
|
||||
} else {
|
||||
} else if (event.modifierFlags > _previouslyPressedFlags) {
|
||||
type = @"keydown";
|
||||
} else {
|
||||
// ignore duplicate modifiers; This can happen in situations like switching
|
||||
// between application windows when MacOS only sends the up event to new window.
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -170,6 +170,16 @@ TEST(FlutterChannelKeyResponderUnittests, BasicKeyEvent) {
|
||||
|
||||
[messages removeAllObjects];
|
||||
[responses removeAllObjects];
|
||||
|
||||
// RShift up again, should be ignored and not produce a keydown event.
|
||||
next_response = false;
|
||||
[responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, 60)
|
||||
callback:^(BOOL handled) {
|
||||
[responses addObject:@(handled)];
|
||||
}];
|
||||
|
||||
EXPECT_EQ([messages count], 0u);
|
||||
EXPECT_EQ([responses count], 0u);
|
||||
}
|
||||
|
||||
TEST(FlutterChannelKeyResponderUnittests, EmptyResponseIsTakenAsHandled) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user