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

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

Issue 10825254: Remove views::KeyEvent, replacing uses of it with ui::KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/button/menu_button.h ('k') | ui/views/controls/combobox/combobox.h » ('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/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "grit/ui_strings.h" 9 #include "grit/ui_strings.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
11 #include "ui/base/dragdrop/drag_drop_types.h" 11 #include "ui/base/dragdrop/drag_drop_types.h"
12 #include "ui/base/event.h"
12 #include "ui/base/events.h" 13 #include "ui/base/events.h"
13 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/screen.h" 18 #include "ui/gfx/screen.h"
18 #include "ui/views/controls/button/button.h" 19 #include "ui/views/controls/button/button.h"
19 #include "ui/views/controls/button/menu_button_listener.h" 20 #include "ui/views/controls/button/menu_button_listener.h"
20 #include "ui/views/events/event.h" 21 #include "ui/views/events/event.h"
21 #include "ui/views/widget/root_view.h" 22 #include "ui/views/widget/root_view.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 221
221 ui::GestureStatus MenuButton::OnGestureEvent(const GestureEvent& event) { 222 ui::GestureStatus MenuButton::OnGestureEvent(const GestureEvent& event) {
222 if (state() != BS_DISABLED && event.type() == ui::ET_GESTURE_TAP) { 223 if (state() != BS_DISABLED && event.type() == ui::ET_GESTURE_TAP) {
223 if (Activate()) 224 if (Activate())
224 return ui::GESTURE_STATUS_CONSUMED; 225 return ui::GESTURE_STATUS_CONSUMED;
225 return ui::GESTURE_STATUS_UNKNOWN; 226 return ui::GESTURE_STATUS_UNKNOWN;
226 } 227 }
227 return TextButton::OnGestureEvent(event); 228 return TextButton::OnGestureEvent(event);
228 } 229 }
229 230
230 bool MenuButton::OnKeyPressed(const KeyEvent& event) { 231 bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) {
231 switch (event.key_code()) { 232 switch (event.key_code()) {
232 case ui::VKEY_SPACE: 233 case ui::VKEY_SPACE:
233 // Alt-space on windows should show the window menu. 234 // Alt-space on windows should show the window menu.
234 if (event.IsAltDown()) 235 if (event.IsAltDown())
235 break; 236 break;
236 case ui::VKEY_RETURN: 237 case ui::VKEY_RETURN:
237 case ui::VKEY_UP: 238 case ui::VKEY_UP:
238 case ui::VKEY_DOWN: { 239 case ui::VKEY_DOWN: {
239 // WARNING: we may have been deleted by the time Activate returns. 240 // WARNING: we may have been deleted by the time Activate returns.
240 return Activate(); 241 return Activate();
241 } 242 }
242 default: 243 default:
243 break; 244 break;
244 } 245 }
245 return false; 246 return false;
246 } 247 }
247 248
248 bool MenuButton::OnKeyReleased(const KeyEvent& event) { 249 bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) {
249 // Override CustomButton's implementation, which presses the button when 250 // Override CustomButton's implementation, which presses the button when
250 // you press space and clicks it when you release space. For a MenuButton 251 // you press space and clicks it when you release space. For a MenuButton
251 // we always activate the menu on key press. 252 // we always activate the menu on key press.
252 return false; 253 return false;
253 } 254 }
254 255
255 void MenuButton::GetAccessibleState(ui::AccessibleViewState* state) { 256 void MenuButton::GetAccessibleState(ui::AccessibleViewState* state) {
256 CustomButton::GetAccessibleState(state); 257 CustomButton::GetAccessibleState(state);
257 state->role = ui::AccessibilityTypes::ROLE_BUTTONMENU; 258 state->role = ui::AccessibilityTypes::ROLE_BUTTONMENU;
258 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 259 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
259 state->state = ui::AccessibilityTypes::STATE_HASPOPUP; 260 state->state = ui::AccessibilityTypes::STATE_HASPOPUP;
260 } 261 }
261 262
262 int MenuButton::GetMaximumScreenXCoordinate() { 263 int MenuButton::GetMaximumScreenXCoordinate() {
263 if (!GetWidget()) { 264 if (!GetWidget()) {
264 NOTREACHED(); 265 NOTREACHED();
265 return 0; 266 return 0;
266 } 267 }
267 268
268 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 269 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
269 return monitor_bounds.right() - 1; 270 return monitor_bounds.right() - 1;
270 } 271 }
271 272
272 } // namespace views 273 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/menu_button.h ('k') | ui/views/controls/combobox/combobox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698