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

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

Issue 6480001: Migrate Event API methods to Google Style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/button/menu_button.h" 5 #include "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/app_strings.h" 8 #include "grit/app_strings.h"
9 #include "grit/app_resources.h" 9 #include "grit/app_resources.h"
10 #include "ui/base/dragdrop/drag_drop_types.h" 10 #include "ui/base/dragdrop/drag_drop_types.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (GetDragOperations(e.location()) != ui::DragDropTypes::DRAG_NONE && 213 if (GetDragOperations(e.location()) != ui::DragDropTypes::DRAG_NONE &&
214 state() != BS_DISABLED && !canceled && !InDrag() && 214 state() != BS_DISABLED && !canceled && !InDrag() &&
215 e.IsOnlyLeftMouseButton() && HitTest(e.location())) { 215 e.IsOnlyLeftMouseButton() && HitTest(e.location())) {
216 Activate(); 216 Activate();
217 } else { 217 } else {
218 TextButton::OnMouseReleased(e, canceled); 218 TextButton::OnMouseReleased(e, canceled);
219 } 219 }
220 } 220 }
221 221
222 bool MenuButton::OnKeyPressed(const KeyEvent& e) { 222 bool MenuButton::OnKeyPressed(const KeyEvent& e) {
223 if (e.GetKeyCode() == ui::VKEY_SPACE || 223 switch (e.key_code()) {
224 e.GetKeyCode() == ui::VKEY_RETURN || 224 case ui::VKEY_SPACE:
225 e.GetKeyCode() == ui::VKEY_UP || 225 case ui::VKEY_RETURN:
226 e.GetKeyCode() == ui::VKEY_DOWN) { 226 case ui::VKEY_UP:
227 bool result = Activate(); 227 case ui::VKEY_DOWN: {
228 if (GetFocusManager()->GetFocusedView() == NULL) 228 bool result = Activate();
229 RequestFocus(); 229 if (GetFocusManager()->GetFocusedView() == NULL)
230 return result; 230 RequestFocus();
231 return result;
232 }
233 default:
234 break;
231 } 235 }
232 return false; 236 return false;
233 } 237 }
234 238
235 bool MenuButton::OnKeyReleased(const KeyEvent& e) { 239 bool MenuButton::OnKeyReleased(const KeyEvent& e) {
236 // Override CustomButton's implementation, which presses the button when 240 // Override CustomButton's implementation, which presses the button when
237 // you press space and clicks it when you release space. For a MenuButton 241 // you press space and clicks it when you release space. For a MenuButton
238 // we always activate the menu on key press. 242 // we always activate the menu on key press.
239 return false; 243 return false;
240 } 244 }
(...skipping 25 matching lines...) Expand all
266 270
267 AccessibilityTypes::State MenuButton::GetAccessibleState() { 271 AccessibilityTypes::State MenuButton::GetAccessibleState() {
268 return AccessibilityTypes::STATE_HASPOPUP; 272 return AccessibilityTypes::STATE_HASPOPUP;
269 } 273 }
270 274
271 std::string MenuButton::GetClassName() const { 275 std::string MenuButton::GetClassName() const {
272 return kViewClassName; 276 return kViewClassName;
273 } 277 }
274 278
275 } // namespace views 279 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698