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.
5 #include "mandoline/ui/aura/input_method_mandoline.h"
7 #include "ui/base/ime/text_input_client.h"
8 #include "ui/events/event.h"
12 ////////////////////////////////////////////////////////////////////////////////
13 // InputMethodMandoline, public:
15 InputMethodMandoline::InputMethodMandoline(
16 ui::internal::InputMethodDelegate
* delegate
) {
17 SetDelegate(delegate
);
20 InputMethodMandoline::~InputMethodMandoline() {}
22 ////////////////////////////////////////////////////////////////////////////////
23 // InputMethodMandoline, ui::InputMethod implementation:
25 bool InputMethodMandoline::OnUntranslatedIMEMessage(
26 const base::NativeEvent
& event
,
27 NativeEventResult
* result
) {
31 bool InputMethodMandoline::DispatchKeyEvent(const ui::KeyEvent
& event
) {
32 DCHECK(event
.type() == ui::ET_KEY_PRESSED
||
33 event
.type() == ui::ET_KEY_RELEASED
);
35 // If no text input client, do nothing.
36 if (!GetTextInputClient())
37 return DispatchKeyEventPostIME(event
);
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());
51 return DispatchKeyEventPostIME(event
);
54 void InputMethodMandoline::OnCaretBoundsChanged(
55 const ui::TextInputClient
* client
) {
58 void InputMethodMandoline::CancelComposition(
59 const ui::TextInputClient
* client
) {
62 void InputMethodMandoline::OnInputLocaleChanged() {
65 std::string
InputMethodMandoline::GetInputLocale() {
69 bool InputMethodMandoline::IsCandidatePopupOpen() const {
73 } // namespace mandoline