Chromium Code Reviews| Index: ui/keyboard/keyboard_util.cc |
| diff --git a/ui/keyboard/keyboard_util.cc b/ui/keyboard/keyboard_util.cc |
| index b5afa09b780d276f5166e8fb6997d86c3b59384c..1252b442f10322afffc308b483ec98fd4bf70b59 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) { |
|
sadrul
2013/09/05 22:54:49
SendProcessKeyEvent
kevers
2013/09/06 00:48:25
Done.
|
| + 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); |
|
sadrul
2013/09/05 22:54:49
I think it'd be simpler if you do:
SendProcessK
kevers
2013/09/06 00:48:25
InsertText does not work for web content as the te
sadrul
2013/09/06 05:52:38
Ah, I see. It feels a bit weird that InsertText()
|
| + } |
| + } 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; |
| } |