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 +6
-4
lines changed
shell/platform/darwin/macos/framework/Source Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -47,18 +47,20 @@ - (void)handleEvent:(NSEvent*)event callback:(FlutterAsyncKeyCallback)callback {
4747 case NSEventTypeKeyUp:
4848 type = @" keyup" ;
4949 break ;
50- case NSEventTypeFlagsChanged:
51- if (event.modifierFlags < _previouslyPressedFlags) {
50+ case NSEventTypeFlagsChanged: {
51+ // Remove the 0x100 bit set by Cocoa when no modifiers are pressed.
52+ NSEventModifierFlags modifierFlags = event.modifierFlags & ~0x100 ;
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
5859 // between application windows when MacOS only sends the up event to new window.
5960 return ;
6061 }
6162 break ;
63+ }
6264 default :
6365 NSAssert (false , @" Unexpected key event type (got %lu )." , event.type);
6466 }
You can’t perform that action at this time.
0 commit comments