| 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/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. | 1187 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. |
| 1188 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops, | 1188 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops, |
| 1189 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); | 1189 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
| 1190 // MenuController may have been deleted if |async_run_| so check for an active | 1190 // MenuController may have been deleted if |async_run_| so check for an active |
| 1191 // instance before accessing member variables. | 1191 // instance before accessing member variables. |
| 1192 if (GetActiveInstance()) | 1192 if (GetActiveInstance()) |
| 1193 did_initiate_drag_ = false; | 1193 did_initiate_drag_ = false; |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 void MenuController::OnKeyDown(ui::KeyboardCode key_code) { | 1196 void MenuController::OnKeyDown(ui::KeyboardCode key_code) { |
| 1197 DCHECK(blocking_run_); | 1197 // Do not process while performing drag-and-drop |
| 1198 if (!blocking_run_) |
| 1199 return; |
| 1198 | 1200 |
| 1199 switch (key_code) { | 1201 switch (key_code) { |
| 1200 case ui::VKEY_UP: | 1202 case ui::VKEY_UP: |
| 1201 IncrementSelection(INCREMENT_SELECTION_UP); | 1203 IncrementSelection(INCREMENT_SELECTION_UP); |
| 1202 break; | 1204 break; |
| 1203 | 1205 |
| 1204 case ui::VKEY_DOWN: | 1206 case ui::VKEY_DOWN: |
| 1205 IncrementSelection(INCREMENT_SELECTION_DOWN); | 1207 IncrementSelection(INCREMENT_SELECTION_DOWN); |
| 1206 break; | 1208 break; |
| 1207 | 1209 |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 } else if (details.index_of_item == -1 || details.next_match == -1) { | 2258 } else if (details.index_of_item == -1 || details.next_match == -1) { |
| 2257 SetSelection(submenu->GetMenuItemAt(details.first_match), | 2259 SetSelection(submenu->GetMenuItemAt(details.first_match), |
| 2258 SELECTION_DEFAULT); | 2260 SELECTION_DEFAULT); |
| 2259 } else { | 2261 } else { |
| 2260 SetSelection(submenu->GetMenuItemAt(details.next_match), | 2262 SetSelection(submenu->GetMenuItemAt(details.next_match), |
| 2261 SELECTION_DEFAULT); | 2263 SELECTION_DEFAULT); |
| 2262 } | 2264 } |
| 2263 } | 2265 } |
| 2264 | 2266 |
| 2265 void MenuController::SelectByChar(base::char16 character) { | 2267 void MenuController::SelectByChar(base::char16 character) { |
| 2268 // Do not process while performing drag-and-drop |
| 2269 if (!blocking_run_) |
| 2270 return; |
| 2266 if (!character) | 2271 if (!character) |
| 2267 return; | 2272 return; |
| 2268 | 2273 |
| 2269 base::char16 char_array[] = { character, 0 }; | 2274 base::char16 char_array[] = { character, 0 }; |
| 2270 base::char16 key = base::i18n::ToLower(char_array)[0]; | 2275 base::char16 key = base::i18n::ToLower(char_array)[0]; |
| 2271 MenuItemView* item = pending_state_.item; | 2276 MenuItemView* item = pending_state_.item; |
| 2272 if (!item->HasSubmenu() || !item->GetSubmenu()->IsShowing()) | 2277 if (!item->HasSubmenu() || !item->GetSubmenu()->IsShowing()) |
| 2273 item = item->GetParentMenuItem(); | 2278 item = item->GetParentMenuItem(); |
| 2274 DCHECK(item); | 2279 DCHECK(item); |
| 2275 DCHECK(item->HasSubmenu()); | 2280 DCHECK(item->HasSubmenu()); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2646 return; | 2651 return; |
| 2647 } | 2652 } |
| 2648 if (hot_button_) | 2653 if (hot_button_) |
| 2649 hot_button_->SetHotTracked(false); | 2654 hot_button_->SetHotTracked(false); |
| 2650 hot_button_ = hot_button; | 2655 hot_button_ = hot_button; |
| 2651 if (hot_button) | 2656 if (hot_button) |
| 2652 hot_button->SetHotTracked(true); | 2657 hot_button->SetHotTracked(true); |
| 2653 } | 2658 } |
| 2654 | 2659 |
| 2655 } // namespace views | 2660 } // namespace views |
| OLD | NEW |