From e6f480f74b6d0a49a5c85f5a18cce25c565d2b13 Mon Sep 17 00:00:00 2001 From: Francisco Magdaleno Date: Tue, 19 Mar 2019 15:58:11 -0700 Subject: [PATCH] Send macOS keyboard data to the engine (flutter/engine#8219) --- .../macos/framework/Source/FLEViewController.mm | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLEViewController.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLEViewController.mm index 76a1e08557..b0f732e310 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLEViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLEViewController.mm @@ -16,12 +16,6 @@ static NSString* const kICUBundlePath = @"icudtl.dat"; static const int kDefaultWindowFramebuffer = 0; -// Android KeyEvent constants from https://developer.android.com/reference/android/view/KeyEvent -static const int kAndroidMetaStateShift = 1 << 0; -static const int kAndroidMetaStateAlt = 1 << 1; -static const int kAndroidMetaStateCtrl = 1 << 12; -static const int kAndroidMetaStateMeta = 1 << 16; - #pragma mark - Private interface declaration. /** @@ -476,14 +470,12 @@ static void CommonInit(FLEViewController* controller) { - (void)dispatchKeyEvent:(NSEvent*)event ofType:(NSString*)type { [_keyEventChannel sendMessage:@{ - @"keymap" : @"android", + @"keymap" : @"macos", @"type" : type, @"keyCode" : @(event.keyCode), - @"metaState" : - @(((event.modifierFlags & NSEventModifierFlagShift) ? kAndroidMetaStateShift : 0) | - ((event.modifierFlags & NSEventModifierFlagOption) ? kAndroidMetaStateAlt : 0) | - ((event.modifierFlags & NSEventModifierFlagControl) ? kAndroidMetaStateCtrl : 0) | - ((event.modifierFlags & NSEventModifierFlagCommand) ? kAndroidMetaStateMeta : 0)) + @"modifiers" : @(event.modifierFlags), + @"characters" : event.characters, + @"charactersIgnoringModifiers" : event.charactersIgnoringModifiers, }]; }