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

Side by Side Diff: ui/views/controls/button/menu_button.cc

Issue 1671323002: [UI Views] Handle accelerators being pressed for buttons inside a menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 4 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
« no previous file with comments | « ui/views/controls/button/menu_button.h ('k') | 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/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/base/dragdrop/drag_drop_types.h" 9 #include "ui/base/dragdrop/drag_drop_types.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return false; 264 return false;
265 } 265 }
266 266
267 bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) { 267 bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) {
268 // Override CustomButton's implementation, which presses the button when 268 // Override CustomButton's implementation, which presses the button when
269 // you press space and clicks it when you release space. For a MenuButton 269 // you press space and clicks it when you release space. For a MenuButton
270 // we always activate the menu on key press. 270 // we always activate the menu on key press.
271 return false; 271 return false;
272 } 272 }
273 273
274 bool MenuButton::AcceleratorPressed(const ui::Accelerator& accelerator) {
275 // CustomButton::AcceleratorPressed ends up in NotifyClick, which doesn't work
276 // for menu buttons.
277 Activate();
278 return true;
279 }
280
274 void MenuButton::GetAccessibleState(ui::AXViewState* state) { 281 void MenuButton::GetAccessibleState(ui::AXViewState* state) {
275 CustomButton::GetAccessibleState(state); 282 CustomButton::GetAccessibleState(state);
276 state->role = ui::AX_ROLE_POP_UP_BUTTON; 283 state->role = ui::AX_ROLE_POP_UP_BUTTON;
277 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 284 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
278 state->AddStateFlag(ui::AX_STATE_HASPOPUP); 285 state->AddStateFlag(ui::AX_STATE_HASPOPUP);
279 } 286 }
280 287
281 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { 288 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) {
282 gfx::Insets insets = GetInsets(); 289 gfx::Insets insets = GetInsets();
283 290
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (!GetWidget()) { 371 if (!GetWidget()) {
365 NOTREACHED(); 372 NOTREACHED();
366 return 0; 373 return 0;
367 } 374 }
368 375
369 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 376 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
370 return monitor_bounds.right() - 1; 377 return monitor_bounds.right() - 1;
371 } 378 }
372 379
373 } // namespace views 380 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/menu_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698