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

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: 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
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return false; 271 return false;
272 } 272 }
273 273
274 void MenuButton::GetAccessibleState(ui::AXViewState* state) { 274 void MenuButton::GetAccessibleState(ui::AXViewState* state) {
275 CustomButton::GetAccessibleState(state); 275 CustomButton::GetAccessibleState(state);
276 state->role = ui::AX_ROLE_POP_UP_BUTTON; 276 state->role = ui::AX_ROLE_POP_UP_BUTTON;
277 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 277 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
278 state->AddStateFlag(ui::AX_STATE_HASPOPUP); 278 state->AddStateFlag(ui::AX_STATE_HASPOPUP);
279 } 279 }
280 280
281 bool MenuButton::AcceleratorPressed(const ui::Accelerator& accelerator) {
282 // CustomButton::AcceleratorPressed ends up in NotifyClick, which doesn't work
283 // for menu buttons.
284 Activate();
varkha 2016/02/06 00:58:08 why not "return Activate();"?
Devlin 2016/02/06 02:04:23 The return value of Activate() is designed for mou
285 return true;
286 }
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
284 // Using the Views mirroring infrastructure incorrectly flips icon content. 291 // Using the Views mirroring infrastructure incorrectly flips icon content.
285 // Instead, manually mirror the position of the down arrow. 292 // Instead, manually mirror the position of the down arrow.
286 gfx::Rect arrow_bounds(width() - insets.right() - 293 gfx::Rect arrow_bounds(width() - insets.right() -
287 menu_marker_->width() - kMenuMarkerPaddingRight, 294 menu_marker_->width() - kMenuMarkerPaddingRight,
288 height() / 2 - menu_marker_->height() / 2, 295 height() / 2 - menu_marker_->height() / 2,
289 menu_marker_->width(), 296 menu_marker_->width(),
290 menu_marker_->height()); 297 menu_marker_->height());
(...skipping 73 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
« ui/views/controls/button/menu_button.h ('K') | « 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