Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 11826012: Pressing control closes any open bookmark bar folder (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 TranslateMessage(&msg); 934 TranslateMessage(&msg);
935 DispatchMessage(&msg); 935 DispatchMessage(&msg);
936 return exit_type_ == EXIT_NONE; 936 return exit_type_ == EXIT_NONE;
937 } 937 }
938 #elif defined(USE_AURA) 938 #elif defined(USE_AURA)
939 bool MenuController::Dispatch(const base::NativeEvent& event) { 939 bool MenuController::Dispatch(const base::NativeEvent& event) {
940 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { 940 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) {
941 aura::Env::GetInstance()->GetDispatcher()->Dispatch(event); 941 aura::Env::GetInstance()->GetDispatcher()->Dispatch(event);
942 return false; 942 return false;
943 } 943 }
944 // We exit the menu and its message loop on control and alt keypress.
945 // So that accelerators such as control-n don't run with a nested
946 // message loop we exit on any modifier that might be used for an
947 // accelerator.
948 // If the user presses control-n, the menu disappears already when
949 // the control key is down. When "n" (while control is still down)
950 // is pressed the shortcut is handled normally after the nested loop
951 // has ended and the context menu has disappeared.
952 // We don't exit the menu on the release of modifiers as the menu
953 // may have been shown by way of an accelerator, eg alt-f. So that
954 // if we exited menus on the release of modifiers the menu would
955 // first appear and then immediately disappear.
956 const ui::EventType event_type = ui::EventTypeFromNative(event);
957 if (event_type == ui::ET_KEY_PRESSED ) {
958 const ui::KeyboardCode key_code = ui::KeyboardCodeFromNative(event);
959 if (key_code == ui::VKEY_LCONTROL || key_code == ui::VKEY_CONTROL ||
960 key_code == ui::VKEY_RCONTROL || key_code == ui::VKEY_MENU ) {
961 Cancel(EXIT_ALL);
962 return false;
963 }
964 }
965 // Activates mnemonics only when it it pressed without modifiers except for 944 // Activates mnemonics only when it it pressed without modifiers except for
966 // caps and shift. 945 // caps and shift.
967 int flags = ui::EventFlagsFromNative(event) & 946 int flags = ui::EventFlagsFromNative(event) &
968 ~ui::EF_CAPS_LOCK_DOWN & ~ui::EF_SHIFT_DOWN; 947 ~ui::EF_CAPS_LOCK_DOWN & ~ui::EF_SHIFT_DOWN;
969 if (flags == ui::EF_NONE) { 948 if (flags == ui::EF_NONE) {
970 switch (event_type) { 949 switch (ui::EventTypeFromNative(event)) {
971 case ui::ET_KEY_PRESSED: 950 case ui::ET_KEY_PRESSED:
972 if (!OnKeyDown(ui::KeyboardCodeFromNative(event))) 951 if (!OnKeyDown(ui::KeyboardCodeFromNative(event)))
973 return false; 952 return false;
974 953
975 return !SelectByChar(ui::KeyboardCodeFromNative(event)); 954 return !SelectByChar(ui::KeyboardCodeFromNative(event));
976 case ui::ET_KEY_RELEASED: 955 case ui::ET_KEY_RELEASED:
977 return true; 956 return true;
978 default: 957 default:
979 break; 958 break;
980 } 959 }
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 (!pending_state_.item->HasSubmenu() || 2124 (!pending_state_.item->HasSubmenu() ||
2146 !pending_state_.item->GetSubmenu()->IsShowing())) { 2125 !pending_state_.item->GetSubmenu()->IsShowing())) {
2147 // On exit if the user hasn't selected an item with a submenu, move the 2126 // On exit if the user hasn't selected an item with a submenu, move the
2148 // selection back to the parent menu item. 2127 // selection back to the parent menu item.
2149 SetSelection(pending_state_.item->GetParentMenuItem(), 2128 SetSelection(pending_state_.item->GetParentMenuItem(),
2150 SELECTION_OPEN_SUBMENU); 2129 SELECTION_OPEN_SUBMENU);
2151 } 2130 }
2152 } 2131 }
2153 2132
2154 } // namespace views 2133 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698