| 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 if (GetInputMethod()) |
| 145 GetInputMethod()->OnFocus(); |
| 143 // Forward the focus to the wrapper. | 146 // Forward the focus to the wrapper. |
| 144 if (native_wrapper_) { | 147 if (native_wrapper_) { |
| 145 native_wrapper_->SetFocus(); | 148 native_wrapper_->SetFocus(); |
| 146 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true); | 149 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true); |
| 147 } else { | 150 } else { |
| 148 View::OnFocus(); // Will focus the RootView window (so we still get | 151 View::OnFocus(); // Will focus the RootView window (so we still get |
| 149 // keyboard messages). | 152 // keyboard messages). |
| 150 } | 153 } |
| 151 } | 154 } |
| 152 | 155 |
| 153 void Combobox::OnBlur() { | 156 void Combobox::OnBlur() { |
| 157 if (GetInputMethod()) |
| 158 GetInputMethod()->OnBlur(); |
| 154 if (selector_) | 159 if (selector_) |
| 155 selector_->OnViewBlur(); | 160 selector_->OnViewBlur(); |
| 156 if (native_wrapper_) | 161 if (native_wrapper_) |
| 157 native_wrapper_->HandleBlur(); | 162 native_wrapper_->HandleBlur(); |
| 158 } | 163 } |
| 159 | 164 |
| 160 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { | 165 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { |
| 161 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; | 166 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; |
| 162 state->name = accessible_name_; | 167 state->name = accessible_name_; |
| 163 state->value = model_->GetItemAt(selected_index_); | 168 state->value = model_->GetItemAt(selected_index_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 179 native_wrapper_->UpdateSelectedIndex(); | 184 native_wrapper_->UpdateSelectedIndex(); |
| 180 native_wrapper_->UpdateEnabled(); | 185 native_wrapper_->UpdateEnabled(); |
| 181 } | 186 } |
| 182 } | 187 } |
| 183 | 188 |
| 184 const char* Combobox::GetClassName() const { | 189 const char* Combobox::GetClassName() const { |
| 185 return kViewClassName; | 190 return kViewClassName; |
| 186 } | 191 } |
| 187 | 192 |
| 188 } // namespace views | 193 } // namespace views |
| OLD | NEW |