From 70bdfedabf5f9e5bfb1acd89f23d1818e9538016 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 28 Sep 2015 02:41:06 +0200 Subject: [PATCH] Added text and unmodifiedtext setting when sending char type keyboard events, and made the type of the character read char16, so I can simulate char events from non-english origins. --- .../native_mate_converters/blink_converter.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index beb60737e7..f1fc1983de 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -9,6 +9,7 @@ #include "atom/common/keyboad_util.h" #include "base/strings/string_util.h" +#include "base/strings/utf_string_conversions.h" #include "content/public/browser/native_web_keyboard_event.h" #include "native_mate/dictionary.h" #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" @@ -29,10 +30,10 @@ int VectorToBitArray(const std::vector& vec) { namespace mate { template<> -struct Converter { +struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Handle val, - char* out) { - std::string code = base::StringToLowerASCII(V8ToString(val)); + base::char16* out) { + base::string16 code = base::UTF8ToUTF16(V8ToString(val)); if (code.length() != 1) return false; *out = code[0]; @@ -157,16 +158,18 @@ bool Converter::FromV8( return false; if (!ConvertFromV8(isolate, val, static_cast(out))) return false; - char code; + base::char16 code; if (!dict.Get("keyCode", &code)) return false; bool shifted = false; out->windowsKeyCode = atom::KeyboardCodeFromCharCode(code, &shifted); - if (out->windowsKeyCode == ui::VKEY_UNKNOWN) - return false; if (shifted) out->modifiers |= blink::WebInputEvent::ShiftKey; out->setKeyIdentifierFromWindowsKeyCode(); + if (out->type == blink::WebInputEvent::Char || out->type == blink::WebInputEvent::RawKeyDown) { + out->text[0] = code; + out->unmodifiedText[0] = code; + } return true; }