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

Side by Side Diff: views/ime/input_method.h

Issue 6688049: New InputMethod api for Views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't dispatch the character when focus was changed by the key event. Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/ime/OWNERS ('k') | views/ime/input_method_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #ifndef VIEWS_IME_INPUT_METHOD_H_
6 #define VIEWS_IME_INPUT_METHOD_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/i18n/rtl.h"
13 #include "ui/base/ime/text_input_type.h"
14
15 namespace views {
16
17 namespace internal {
18 class InputMethodDelegate;
19 } // namespace internal
20
21 class KeyEvent;
22 class TextInputClient;
23 class View;
24 class Widget;
25
26 // An interface implemented by an object that encapsulates a native input method
27 // service provided by the underlying operation system.
28 // Because on most systems, the system input method service is bound to
29 // individual native window. On Windows, its HWND, on Linux/Gtk, its GdkWindow.
30 // And in Views control system, only the top-level NativeWidget has a native
31 // window that can get keyboard focus. So this API is designed to be bound to
32 // the top-level NativeWidget.
33 class InputMethod {
34 public:
35 virtual ~InputMethod() {}
36
37 // Sets the delegate used by this InputMethod instance. It should only be
38 // called by the internal NativeWidget or testing code.
39 virtual void set_delegate(internal::InputMethodDelegate* delegate) = 0;
40
41 // Initialize the InputMethod object and attach it to the given |widget|.
42 // The |widget| must already be initialized.
43 virtual void Init(Widget* widget) = 0;
44
45 // Called when the top-level NativeWidget gets keyboard focus. It should only
46 // be called by the top-level NativeWidget which owns this InputMethod
47 // instance.
48 virtual void OnFocus() = 0;
49
50 // Called when the top-level NativeWidget loses keyboard focus. It should only
51 // be called by the top-level NativeWidget which owns this InputMethod
52 // instance.
53 virtual void OnBlur() = 0;
54
55 // Dispatch a key event to the input method. The key event will be dispatched
56 // back to the caller via InputMethodDelegate::DispatchKeyEventPostIME(), once
57 // it's processed by the input method. It should only be called by the
58 // top-level NativeWidget which owns this InputMethod instance, or other
59 // related platform dependent code, such as a message dispatcher.
60 virtual void DispatchKeyEvent(const KeyEvent& key) = 0;
61
62 // Called by the focused |view| whenever its text input type is changed.
63 // Before calling this method, the focused |view| must confirm or clear
64 // existing composition text and call InputMethod::CancelComposition() when
65 // necessary. Otherwise unexpected behavior may happen. This method has no
66 // effect if the |view| is not focused.
67 virtual void OnTextInputTypeChanged(View* view) = 0;
68
69 // Called by the focused |view| whenever its caret bounds is changed.
70 // This method has no effect if the |view| is not focused.
71 virtual void OnCaretBoundsChanged(View* view) = 0;
72
73 // Called by the focused |view| to ask the input method cancel the ongoing
74 // composition session. This method has no effect if the |view| is not
75 // focused.
76 virtual void CancelComposition(View* view) = 0;
77
78 // Returns the locale of current keyboard layout or input method, as a BCP-47
79 // tag, or an empty string if the input method cannot provide it.
80 virtual std::string GetInputLocale() = 0;
81
82 // Returns the text direction of current keyboard layout or input method, or
83 // base::i18n::UNKNOWN_DIRECTION if the input method cannot provide it.
84 virtual base::i18n::TextDirection GetInputTextDirection() = 0;
85
86 // Checks if the input method is active, i.e. if it's ready for processing
87 // keyboard event and generate composition or text result.
88 // If the input method is inactive, then it's not necessary to inform it the
89 // changes of caret bounds and text input type.
90 // Note: character results may still be generated and sent to the text input
91 // client by calling TextInputClient::InsertChar(), even if the input method
92 // is not active.
93 virtual bool IsActive() = 0;
94
95 // Gets the focused text input client. Returns NULL if the Widget is not
96 // focused, or there is no focused View or the focused View doesn't support
97 // text input.
98 virtual TextInputClient* GetTextInputClient() const = 0;
99
100 // Gets the text input type of the focused text input client. Returns
101 // ui::TEXT_INPUT_TYPE_NONE if there is no focused text input client.
102 virtual ui::TextInputType GetTextInputType() const = 0;
103
104 // TODO(suzhe): Support mouse/touch event.
105 };
106
107 } // namespace views
108
109 #endif // VIEWS_IME_INPUT_METHOD_H_
OLDNEW
« no previous file with comments | « views/ime/OWNERS ('k') | views/ime/input_method_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698