Send macOS keyboard data to the engine (flutter/engine#8219)

This commit is contained in:
Francisco Magdaleno
2019-03-19 15:58:11 -07:00
committed by GitHub
parent 06a23ac247
commit e6f480f74b

View File

@@ -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,
}];
}