OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mandoline/ui/aura/input_method_mandoline.h" |
| 6 |
| 7 #include "ui/base/ime/text_input_client.h" |
| 8 #include "ui/events/event.h" |
| 9 |
| 10 namespace mandoline { |
| 11 |
| 12 //////////////////////////////////////////////////////////////////////////////// |
| 13 // InputMethodMandoline, public: |
| 14 |
| 15 InputMethodMandoline::InputMethodMandoline( |
| 16 ui::internal::InputMethodDelegate* delegate) { |
| 17 SetDelegate(delegate); |
| 18 } |
| 19 |
| 20 InputMethodMandoline::~InputMethodMandoline() {} |
| 21 |
| 22 //////////////////////////////////////////////////////////////////////////////// |
| 23 // InputMethodMandoline, ui::InputMethod implementation: |
| 24 |
| 25 bool InputMethodMandoline::OnUntranslatedIMEMessage( |
| 26 const base::NativeEvent& event, |
| 27 NativeEventResult* result) { |
| 28 return false; |
| 29 } |
| 30 |
| 31 bool InputMethodMandoline::DispatchKeyEvent(const ui::KeyEvent& event) { |
| 32 DCHECK(event.type() == ui::ET_KEY_PRESSED || |
| 33 event.type() == ui::ET_KEY_RELEASED); |
| 34 |
| 35 // If no text input client, do nothing. |
| 36 if (!GetTextInputClient()) |
| 37 return DispatchKeyEventPostIME(event); |
| 38 |
| 39 // Here is where we change the differ from our base class's logic. Instead of |
| 40 // always dispatching a key down event, and then sending a synthesized |
| 41 // character event, we instead check to see if this is a character event and |
| 42 // send out the key if it is. (We fallback to normal dispatch if it isn't.) |
| 43 if (event.is_char()) { |
| 44 const uint16 ch = event.GetCharacter(); |
| 45 if (GetTextInputClient()) |
| 46 GetTextInputClient()->InsertChar(ch, event.flags()); |
| 47 |
| 48 return false; |
| 49 } |
| 50 |
| 51 return DispatchKeyEventPostIME(event); |
| 52 } |
| 53 |
| 54 void InputMethodMandoline::OnCaretBoundsChanged( |
| 55 const ui::TextInputClient* client) { |
| 56 } |
| 57 |
| 58 void InputMethodMandoline::CancelComposition( |
| 59 const ui::TextInputClient* client) { |
| 60 } |
| 61 |
| 62 void InputMethodMandoline::OnInputLocaleChanged() { |
| 63 } |
| 64 |
| 65 std::string InputMethodMandoline::GetInputLocale() { |
| 66 return ""; |
| 67 } |
| 68 |
| 69 bool InputMethodMandoline::IsActive() { |
| 70 return true; |
| 71 } |
| 72 |
| 73 bool InputMethodMandoline::IsCandidatePopupOpen() const { |
| 74 return false; |
| 75 } |
| 76 |
| 77 } // namespace mandoline |
OLD | NEW |