| 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/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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |