This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
shell/platform/darwin/macos/framework/Source Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ - (nonnull instancetype)initWithChannel:(nonnull FlutterBasicMessageChannel*)cha
39
39
}
40
40
41
41
- (void )handleEvent : (NSEvent *)event callback : (FlutterAsyncKeyCallback)callback {
42
+ // Remove the 0x100 bit set by Cocoa when no modifiers are pressed.
43
+ NSEventModifierFlags modifierFlags = event.modifierFlags & ~0x100 ;
42
44
NSString * type;
43
45
switch (event.type ) {
44
46
case NSEventTypeKeyDown:
@@ -48,10 +50,9 @@ - (void)handleEvent:(NSEvent*)event callback:(FlutterAsyncKeyCallback)callback {
48
50
type = @" keyup" ;
49
51
break ;
50
52
case NSEventTypeFlagsChanged:
51
- if (event. modifierFlags < _previouslyPressedFlags) {
53
+ if (modifierFlags < _previouslyPressedFlags) {
52
54
type = @" keyup" ;
53
- } else if (event.modifierFlags > _previouslyPressedFlags &&
54
- event.modifierFlags > 0x100 ) { // 0x100 is empty modifierFlags
55
+ } else if (modifierFlags > _previouslyPressedFlags) {
55
56
type = @" keydown" ;
56
57
} else {
57
58
// ignore duplicate modifiers; This can happen in situations like switching
@@ -62,7 +63,7 @@ - (void)handleEvent:(NSEvent*)event callback:(FlutterAsyncKeyCallback)callback {
62
63
default :
63
64
NSAssert (false , @" Unexpected key event type (got %lu )." , event.type);
64
65
}
65
- _previouslyPressedFlags = event. modifierFlags ;
66
+ _previouslyPressedFlags = modifierFlags;
66
67
NSMutableDictionary * keyMessage = [@{
67
68
@" keymap" : @" macos" ,
68
69
@" type" : type,
You can’t perform that action at this time.
0 commit comments