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/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 #endif | 536 #endif |
537 | 537 |
538 ui::GestureStatus MenuController::OnGestureEvent(SubmenuView* source, | 538 ui::GestureStatus MenuController::OnGestureEvent(SubmenuView* source, |
539 const GestureEvent& event) { | 539 const GestureEvent& event) { |
540 if (event.type() == ui::ET_GESTURE_TAP_DOWN) { | 540 if (event.type() == ui::ET_GESTURE_TAP_DOWN) { |
541 SetSelectionOnPointerDown(source, event); | 541 SetSelectionOnPointerDown(source, event); |
542 return ui::GESTURE_STATUS_CONSUMED; | 542 return ui::GESTURE_STATUS_CONSUMED; |
543 } else if (event.type() == ui::ET_GESTURE_LONG_PRESS && possible_drag_) { | 543 } else if (event.type() == ui::ET_GESTURE_LONG_PRESS && possible_drag_) { |
544 StartDrag(source, event.location()); | 544 StartDrag(source, event.location()); |
545 return ui::GESTURE_STATUS_CONSUMED; | 545 return ui::GESTURE_STATUS_CONSUMED; |
| 546 } else if (event.type() == ui::ET_GESTURE_TAP) { |
| 547 if (pending_state_.item) { |
| 548 if (pending_state_.item->HasSubmenu()) |
| 549 OpenSubmenuChangeSelectionIfCan(); |
| 550 else if (pending_state_.item->enabled()) |
| 551 Accept(pending_state_.item, 0); |
| 552 return ui::GESTURE_STATUS_CONSUMED; |
| 553 } |
546 } | 554 } |
547 MenuPart part = GetMenuPart(source, event.location()); | 555 MenuPart part = GetMenuPart(source, event.location()); |
548 if (!part.submenu) | 556 if (!part.submenu) |
549 return ui::GESTURE_STATUS_UNKNOWN; | 557 return ui::GESTURE_STATUS_UNKNOWN; |
550 return part.submenu->OnGestureEvent(event); | 558 return part.submenu->OnGestureEvent(event); |
551 } | 559 } |
552 | 560 |
553 bool MenuController::GetDropFormats( | 561 bool MenuController::GetDropFormats( |
554 SubmenuView* source, | 562 SubmenuView* source, |
555 int* formats, | 563 int* formats, |
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 (!pending_state_.item->HasSubmenu() || | 2095 (!pending_state_.item->HasSubmenu() || |
2088 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2096 !pending_state_.item->GetSubmenu()->IsShowing())) { |
2089 // On exit if the user hasn't selected an item with a submenu, move the | 2097 // On exit if the user hasn't selected an item with a submenu, move the |
2090 // selection back to the parent menu item. | 2098 // selection back to the parent menu item. |
2091 SetSelection(pending_state_.item->GetParentMenuItem(), | 2099 SetSelection(pending_state_.item->GetParentMenuItem(), |
2092 SELECTION_OPEN_SUBMENU); | 2100 SELECTION_OPEN_SUBMENU); |
2093 } | 2101 } |
2094 } | 2102 } |
2095 | 2103 |
2096 } // namespace views | 2104 } // namespace views |
OLD | NEW |