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
3939}
4040
4141- (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 ;
4244 NSString * type;
4345 switch (event.type ) {
4446 case NSEventTypeKeyDown:
@@ -48,10 +50,9 @@ - (void)handleEvent:(NSEvent*)event callback:(FlutterAsyncKeyCallback)callback {
4850 type = @" keyup" ;
4951 break ;
5052 case NSEventTypeFlagsChanged:
51- if (event. modifierFlags < _previouslyPressedFlags) {
53+ if (modifierFlags < _previouslyPressedFlags) {
5254 type = @" keyup" ;
53- } else if (event.modifierFlags > _previouslyPressedFlags &&
54- event.modifierFlags > 0x100 ) { // 0x100 is empty modifierFlags
55+ } else if (modifierFlags > _previouslyPressedFlags) {
5556 type = @" keydown" ;
5657 } else {
5758 // ignore duplicate modifiers; This can happen in situations like switching
@@ -62,7 +63,7 @@ - (void)handleEvent:(NSEvent*)event callback:(FlutterAsyncKeyCallback)callback {
6263 default :
6364 NSAssert (false , @" Unexpected key event type (got %lu )." , event.type);
6465 }
65- _previouslyPressedFlags = event. modifierFlags ;
66+ _previouslyPressedFlags = modifierFlags;
6667 NSMutableDictionary * keyMessage = [@{
6768 @" keymap" : @" macos" ,
6869 @" type" : type,
You can’t perform that action at this time.
0 commit comments