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(); | |
144 // Forward the focus to the wrapper. | 143 // Forward the focus to the wrapper. |
145 if (native_wrapper_) | 144 if (native_wrapper_) { |
146 native_wrapper_->SetFocus(); | 145 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 } |
147 } | 151 } |
148 | 152 |
149 void Combobox::OnBlur() { | 153 void Combobox::OnBlur() { |
150 View::OnBlur(); | |
151 if (selector_) | 154 if (selector_) |
152 selector_->OnViewBlur(); | 155 selector_->OnViewBlur(); |
153 if (native_wrapper_) | 156 if (native_wrapper_) |
154 native_wrapper_->HandleBlur(); | 157 native_wrapper_->HandleBlur(); |
155 } | 158 } |
156 | 159 |
157 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { | 160 void Combobox::GetAccessibleState(ui::AccessibleViewState* state) { |
158 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; | 161 state->role = ui::AccessibilityTypes::ROLE_COMBOBOX; |
159 state->name = accessible_name_; | 162 state->name = accessible_name_; |
160 state->value = model_->GetItemAt(selected_index_); | 163 state->value = model_->GetItemAt(selected_index_); |
(...skipping 15 matching lines...) Expand all Loading... |
176 native_wrapper_->UpdateSelectedIndex(); | 179 native_wrapper_->UpdateSelectedIndex(); |
177 native_wrapper_->UpdateEnabled(); | 180 native_wrapper_->UpdateEnabled(); |
178 } | 181 } |
179 } | 182 } |
180 | 183 |
181 const char* Combobox::GetClassName() const { | 184 const char* Combobox::GetClassName() const { |
182 return kViewClassName; | 185 return kViewClassName; |
183 } | 186 } |
184 | 187 |
185 } // namespace views | 188 } // namespace views |
OLD | NEW |