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/app_list/search_result_list_view.h" | 5 #include "ui/app_list/search_result_list_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 bool SearchResultListView::OnKeyPressed(const ui::KeyEvent& event) { | 76 bool SearchResultListView::OnKeyPressed(const ui::KeyEvent& event) { |
77 switch (event.key_code()) { | 77 switch (event.key_code()) { |
78 case ui::VKEY_UP: | 78 case ui::VKEY_UP: |
79 SetSelectedIndex(std::max(selected_index_ - 1, 0)); | 79 SetSelectedIndex(std::max(selected_index_ - 1, 0)); |
80 return true; | 80 return true; |
81 case ui::VKEY_DOWN: | 81 case ui::VKEY_DOWN: |
82 SetSelectedIndex(std::min(selected_index_ + 1, last_visible_index_)); | 82 SetSelectedIndex(std::min(selected_index_ + 1, last_visible_index_)); |
83 return true; | 83 return true; |
84 case ui::VKEY_RETURN: | 84 case ui::VKEY_RETURN: |
85 if (selected_index_ >= 0) { | 85 if (selected_index_ >= 0) |
86 // TODO(beng): remove once views::Event is gone. | 86 ButtonPressed(GetResultViewAt(selected_index_), event); |
87 views::MouseEvent synthetic_event( | |
88 ui::ET_MOUSE_RELEASED, 0, 0, | |
89 ui::EF_LEFT_MOUSE_BUTTON | event.flags()); | |
90 ButtonPressed(GetResultViewAt(selected_index_), synthetic_event); | |
91 } | |
92 return true; | 87 return true; |
93 default: | 88 default: |
94 break; | 89 break; |
95 } | 90 } |
96 return false; | 91 return false; |
97 } | 92 } |
98 | 93 |
99 SearchResultView* SearchResultListView::GetResultViewAt(int index) { | 94 SearchResultView* SearchResultListView::GetResultViewAt(int index) { |
100 DCHECK(index >= 0 && index < child_count()); | 95 DCHECK(index >= 0 && index < child_count()); |
101 return static_cast<SearchResultView*>(child_at(index)); | 96 return static_cast<SearchResultView*>(child_at(index)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 GetResultViewAt(i)->ClearResultNoRepaint(); | 151 GetResultViewAt(i)->ClearResultNoRepaint(); |
157 | 152 |
158 ScheduleUpdate(); | 153 ScheduleUpdate(); |
159 } | 154 } |
160 | 155 |
161 void SearchResultListView::ListItemsChanged(size_t start, size_t count) { | 156 void SearchResultListView::ListItemsChanged(size_t start, size_t count) { |
162 ScheduleUpdate(); | 157 ScheduleUpdate(); |
163 } | 158 } |
164 | 159 |
165 } // namespace app_list | 160 } // namespace app_list |
OLD | NEW |