| 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" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 bool Combobox::OnKeyPressed(const ui::KeyEvent& e) { | 134 bool Combobox::OnKeyPressed(const ui::KeyEvent& e) { |
| 135 return native_wrapper_ && native_wrapper_->HandleKeyPressed(e); | 135 return native_wrapper_ && native_wrapper_->HandleKeyPressed(e); |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool Combobox::OnKeyReleased(const ui::KeyEvent& e) { | 138 bool Combobox::OnKeyReleased(const ui::KeyEvent& e) { |
| 139 return native_wrapper_ && native_wrapper_->HandleKeyReleased(e); | 139 return native_wrapper_ && native_wrapper_->HandleKeyReleased(e); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void Combobox::OnFocus() { | 142 void Combobox::OnFocus() { |
| 143 View::OnFocus(); |
| 143 // Forward the focus to the wrapper. | 144 // Forward the focus to the wrapper. |
| 144 if (native_wrapper_) { | 145 if (native_wrapper_) |
| 145 native_wrapper_->SetFocus(); | 146 native_wrapper_->SetFocus(); |
| 146 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true); | |
| 147 } else { | |
| 148 View::OnFocus(); // Will focus the RootView window (so we still get | |
| 149 // keyboard messages). | |
| 150 } | |
| 151 } | 147 } |
| 152 | 148 |
| 153 void Combobox::OnBlur() { | 149 void Combobox::OnBlur() { |
| 150 View::OnBlur(); |
| 154 if (selector_) | 151 if (selector_) |
| 155 selector_->OnViewBlur(); | 152 selector_->OnViewBlur(); |
| 156 if (native_wrapper_) | 153 if (native_wrapper_) |
| 157 native_wrapper_->HandleBlur(); | 154 native_wrapper_->HandleBlur(); |
| 158 } | 155 } |
| 159 | 156 |
| 160 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { | 157 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { |
| 161 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; | 158 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; |
| 162 state->name = accessible_name_; | 159 state->name = accessible_name_; |
| 163 state->value = model_->GetItemAt(selected_index_); | 160 state->value = model_->GetItemAt(selected_index_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 179 native_wrapper_->UpdateSelectedIndex(); | 176 native_wrapper_->UpdateSelectedIndex(); |
| 180 native_wrapper_->UpdateEnabled(); | 177 native_wrapper_->UpdateEnabled(); |
| 181 } | 178 } |
| 182 } | 179 } |
| 183 | 180 |
| 184 const char* Combobox::GetClassName() const { | 181 const char* Combobox::GetClassName() const { |
| 185 return kViewClassName; | 182 return kViewClassName; |
| 186 } | 183 } |
| 187 | 184 |
| 188 } // namespace views | 185 } // namespace views |
| OLD | NEW |