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

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

Issue 167643003: Support prefix typing in Combobox while menu is open (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retry upload Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/controls/menu/menu_runner.cc » ('j') | 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 else 1117 else
1118 CloseSubmenu(); 1118 CloseSubmenu();
1119 break; 1119 break;
1120 1120
1121 case ui::VKEY_SPACE: 1121 case ui::VKEY_SPACE:
1122 if (SendAcceleratorToHotTrackedView() == ACCELERATOR_PROCESSED_EXIT) 1122 if (SendAcceleratorToHotTrackedView() == ACCELERATOR_PROCESSED_EXIT)
1123 return false; 1123 return false;
1124 break; 1124 break;
1125 1125
1126 case ui::VKEY_F4: 1126 case ui::VKEY_F4:
1127 if (!accept_on_f4_) 1127 if (!is_combobox_)
1128 break; 1128 break;
1129 // Fallthrough to accept on F4, so combobox menus match Windows behavior. 1129 // Fallthrough to accept on F4, so combobox menus match Windows behavior.
1130 case ui::VKEY_RETURN: 1130 case ui::VKEY_RETURN:
1131 if (pending_state_.item) { 1131 if (pending_state_.item) {
1132 if (pending_state_.item->HasSubmenu()) { 1132 if (pending_state_.item->HasSubmenu()) {
1133 OpenSubmenuChangeSelectionIfCan(); 1133 OpenSubmenuChangeSelectionIfCan();
1134 } else { 1134 } else {
1135 SendAcceleratorResultType result = SendAcceleratorToHotTrackedView(); 1135 SendAcceleratorResultType result = SendAcceleratorToHotTrackedView();
1136 if (result == ACCELERATOR_NOT_PROCESSED && 1136 if (result == ACCELERATOR_NOT_PROCESSED &&
1137 pending_state_.item->enabled()) { 1137 pending_state_.item->enabled()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 valid_drop_coordinates_(false), 1184 valid_drop_coordinates_(false),
1185 last_drop_operation_(MenuDelegate::DROP_UNKNOWN), 1185 last_drop_operation_(MenuDelegate::DROP_UNKNOWN),
1186 showing_submenu_(false), 1186 showing_submenu_(false),
1187 menu_button_(NULL), 1187 menu_button_(NULL),
1188 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()), 1188 active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()),
1189 delegate_(delegate), 1189 delegate_(delegate),
1190 message_loop_depth_(0), 1190 message_loop_depth_(0),
1191 menu_config_(theme), 1191 menu_config_(theme),
1192 closing_event_time_(base::TimeDelta()), 1192 closing_event_time_(base::TimeDelta()),
1193 menu_start_time_(base::TimeTicks()), 1193 menu_start_time_(base::TimeTicks()),
1194 accept_on_f4_(false), 1194 is_combobox_(false),
1195 item_selected_by_touch_(false) { 1195 item_selected_by_touch_(false) {
1196 active_instance_ = this; 1196 active_instance_ = this;
1197 } 1197 }
1198 1198
1199 MenuController::~MenuController() { 1199 MenuController::~MenuController() {
1200 DCHECK(!showing_); 1200 DCHECK(!showing_);
1201 if (owner_) 1201 if (owner_)
1202 owner_->RemoveObserver(this); 1202 owner_->RemoveObserver(this);
1203 if (active_instance_ == this) 1203 if (active_instance_ == this)
1204 active_instance_ = NULL; 1204 active_instance_ = NULL;
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 DCHECK(item->GetSubmenu()); 2109 DCHECK(item->GetSubmenu());
2110 if (item->GetSubmenu()->GetMenuItemCount() == 0) 2110 if (item->GetSubmenu()->GetMenuItemCount() == 0)
2111 return false; 2111 return false;
2112 2112
2113 // Look for matches based on mnemonic first. 2113 // Look for matches based on mnemonic first.
2114 SelectByCharDetails details = 2114 SelectByCharDetails details =
2115 FindChildForMnemonic(item, key, &MatchesMnemonic); 2115 FindChildForMnemonic(item, key, &MatchesMnemonic);
2116 if (details.first_match != -1) 2116 if (details.first_match != -1)
2117 return AcceptOrSelect(item, details); 2117 return AcceptOrSelect(item, details);
2118 2118
2119 // If no mnemonics found, look at first character of titles. 2119 if (is_combobox_) {
2120 details = FindChildForMnemonic(item, key, &TitleMatchesMnemonic); 2120 item->GetSubmenu()->GetTextInputClient()->InsertChar(character, 0);
2121 if (details.first_match != -1) 2121 } else {
2122 return AcceptOrSelect(item, details); 2122 // If no mnemonics found, look at first character of titles.
2123 details = FindChildForMnemonic(item, key, &TitleMatchesMnemonic);
2124 if (details.first_match != -1)
2125 return AcceptOrSelect(item, details);
2126 }
2123 2127
2124 return false; 2128 return false;
2125 } 2129 }
2126 2130
2127 void MenuController::RepostEvent(SubmenuView* source, 2131 void MenuController::RepostEvent(SubmenuView* source,
2128 const ui::LocatedEvent& event) { 2132 const ui::LocatedEvent& event) {
2129 gfx::Point screen_loc(event.location()); 2133 gfx::Point screen_loc(event.location());
2130 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); 2134 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
2131 2135
2132 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); 2136 gfx::NativeView native_view = source->GetWidget()->GetNativeView();
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 (!pending_state_.item->HasSubmenu() || 2343 (!pending_state_.item->HasSubmenu() ||
2340 !pending_state_.item->GetSubmenu()->IsShowing())) { 2344 !pending_state_.item->GetSubmenu()->IsShowing())) {
2341 // On exit if the user hasn't selected an item with a submenu, move the 2345 // On exit if the user hasn't selected an item with a submenu, move the
2342 // selection back to the parent menu item. 2346 // selection back to the parent menu item.
2343 SetSelection(pending_state_.item->GetParentMenuItem(), 2347 SetSelection(pending_state_.item->GetParentMenuItem(),
2344 SELECTION_OPEN_SUBMENU); 2348 SELECTION_OPEN_SUBMENU);
2345 } 2349 }
2346 } 2350 }
2347 2351
2348 } // namespace views 2352 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/controls/menu/menu_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698