Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Unified Diff: ui/keyboard/keyboard_util.cc

Issue 23536030: Fix typing of accented characters on the VK in Google Docs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix formatting. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/keyboard/keyboard_util.cc
diff --git a/ui/keyboard/keyboard_util.cc b/ui/keyboard/keyboard_util.cc
index b5afa09b780d276f5166e8fb6997d86c3b59384c..0b24a414a00abe0e6d83dd7906f618a763c7cd50 100644
--- a/ui/keyboard/keyboard_util.cc
+++ b/ui/keyboard/keyboard_util.cc
@@ -22,6 +22,13 @@ namespace {
const char kKeyDown[] ="keydown";
const char kKeyUp[] = "keyup";
+void SendProcessKeyEvent(ui::EventType type, aura::RootWindow* root_window) {
+ ui::TranslatedKeyEvent event(type == ui::ET_KEY_PRESSED,
+ ui::VKEY_PROCESSKEY,
+ ui::EF_NONE);
+ root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&event);
+}
+
} // namespace
namespace keyboard {
@@ -107,18 +114,24 @@ bool SendKeyEvent(const std::string type,
ui::KeyboardCode code = static_cast<ui::KeyboardCode>(key_code);
- ui::KeyEvent event(event_type, code, flags, false);
- event.set_character(key_value);
- event.set_unmodified_character(key_value);
-
- if (code != ui::VKEY_UNKNOWN) {
+ if (code == ui::VKEY_UNKNOWN) {
+ // Handling of special printable characters (e.g. accented characters) for
+ // which there is no key code.
+ if (event_type == ui::ET_KEY_RELEASED) {
+ ui::InputMethod* input_method = root_window->GetProperty(
+ aura::client::kRootWindowInputMethodKey);
+ if (!input_method)
+ return false;
+
+ ui::TextInputClient* tic = input_method->GetTextInputClient();
+
+ SendProcessKeyEvent(ui::ET_KEY_PRESSED, root_window);
+ tic->InsertChar(static_cast<uint16>(key_value), ui::EF_NONE);
+ SendProcessKeyEvent(ui::ET_KEY_RELEASED, root_window);
+ }
+ } else {
+ ui::KeyEvent event(event_type, code, flags, false);
root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&event);
- } else if (event_type == ui::ET_KEY_RELEASED) {
- // TODO(kevers): Fix key handling to support key_value when code is
- // VKEY_UNKNOWN.
- base::string16 text;
- text.push_back(static_cast<char16>(key_value));
- InsertText(text, root_window);
}
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698