OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/controls/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "ui/base/accessibility/accessible_view_state.h" | 9 #include "ui/base/accessibility/accessible_view_state.h" |
10 #include "ui/base/events/event.h" | 10 #include "ui/base/events/event.h" |
11 #include "ui/base/keycodes/keyboard_codes.h" | 11 #include "ui/base/keycodes/keyboard_codes.h" |
12 #include "ui/base/models/combobox_model.h" | 12 #include "ui/base/models/combobox_model.h" |
13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/views/controls/combobox/combobox_listener.h" | 14 #include "ui/views/controls/combobox/combobox_listener.h" |
15 #include "ui/views/controls/native/native_view_host.h" | 15 #include "ui/views/controls/native/native_view_host.h" |
16 #include "ui/views/controls/prefix_selector.h" | 16 #include "ui/views/controls/prefix_selector.h" |
| 17 #include "ui/views/ime/input_method.h" |
17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
18 | 19 |
19 namespace views { | 20 namespace views { |
20 | 21 |
21 // static | 22 // static |
22 const char Combobox::kViewClassName[] = "Combobox"; | 23 const char Combobox::kViewClassName[] = "Combobox"; |
23 | 24 |
24 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
25 // Combobox, public: | 26 // Combobox, public: |
26 | 27 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 134 |
134 bool Combobox::OnKeyPressed(const ui::KeyEvent& e) { | 135 bool Combobox::OnKeyPressed(const ui::KeyEvent& e) { |
135 return native_wrapper_ && native_wrapper_->HandleKeyPressed(e); | 136 return native_wrapper_ && native_wrapper_->HandleKeyPressed(e); |
136 } | 137 } |
137 | 138 |
138 bool Combobox::OnKeyReleased(const ui::KeyEvent& e) { | 139 bool Combobox::OnKeyReleased(const ui::KeyEvent& e) { |
139 return native_wrapper_ && native_wrapper_->HandleKeyReleased(e); | 140 return native_wrapper_ && native_wrapper_->HandleKeyReleased(e); |
140 } | 141 } |
141 | 142 |
142 void Combobox::OnFocus() { | 143 void Combobox::OnFocus() { |
| 144 GetInputMethod()->OnFocus(); |
143 // Forward the focus to the wrapper. | 145 // Forward the focus to the wrapper. |
144 if (native_wrapper_) { | 146 if (native_wrapper_) { |
145 native_wrapper_->SetFocus(); | 147 native_wrapper_->SetFocus(); |
146 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true); | 148 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true); |
147 } else { | 149 } else { |
148 View::OnFocus(); // Will focus the RootView window (so we still get | 150 View::OnFocus(); // Will focus the RootView window (so we still get |
149 // keyboard messages). | 151 // keyboard messages). |
150 } | 152 } |
151 } | 153 } |
152 | 154 |
153 void Combobox::OnBlur() { | 155 void Combobox::OnBlur() { |
| 156 GetInputMethod()->OnBlur(); |
154 if (selector_) | 157 if (selector_) |
155 selector_->OnViewBlur(); | 158 selector_->OnViewBlur(); |
156 if (native_wrapper_) | 159 if (native_wrapper_) |
157 native_wrapper_->HandleBlur(); | 160 native_wrapper_->HandleBlur(); |
158 } | 161 } |
159 | 162 |
160 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { | 163 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { |
161 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; | 164 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; |
162 state->name = accessible_name_; | 165 state->name = accessible_name_; |
163 state->value = model_->GetItemAt(selected_index_); | 166 state->value = model_->GetItemAt(selected_index_); |
(...skipping 15 matching lines...) Expand all Loading... |
179 native_wrapper_->UpdateSelectedIndex(); | 182 native_wrapper_->UpdateSelectedIndex(); |
180 native_wrapper_->UpdateEnabled(); | 183 native_wrapper_->UpdateEnabled(); |
181 } | 184 } |
182 } | 185 } |
183 | 186 |
184 const char* Combobox::GetClassName() const { | 187 const char* Combobox::GetClassName() const { |
185 return kViewClassName; | 188 return kViewClassName; |
186 } | 189 } |
187 | 190 |
188 } // namespace views | 191 } // namespace views |
OLD | NEW |