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

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

Issue 1437523005: Custom buttons should only handle accelerators when focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: msw comments Created 5 years, 1 month 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/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "ui/accessibility/ax_view_state.h" 7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 event->StopPropagation(); 244 event->StopPropagation();
245 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL || 245 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
246 event->type() == ui::ET_GESTURE_END) { 246 event->type() == ui::ET_GESTURE_END) {
247 SetState(STATE_NORMAL); 247 SetState(STATE_NORMAL);
248 } 248 }
249 if (!event->handled()) 249 if (!event->handled())
250 Button::OnGestureEvent(event); 250 Button::OnGestureEvent(event);
251 } 251 }
252 252
253 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { 253 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) {
254 if (GetWidget() && !GetWidget()->IsActive())
255 return false;
254 SetState(STATE_NORMAL); 256 SetState(STATE_NORMAL);
255 // TODO(beng): remove once NotifyClick takes ui::Event. 257 // TODO(beng): remove once NotifyClick takes ui::Event.
256 ui::MouseEvent synthetic_event( 258 ui::MouseEvent synthetic_event(
257 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 259 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
258 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 260 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
259 NotifyClick(synthetic_event); 261 NotifyClick(synthetic_event);
260 return true; 262 return true;
261 } 263 }
262 264
263 void CustomButton::ShowContextMenu(const gfx::Point& p, 265 void CustomButton::ShowContextMenu(const gfx::Point& p,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if (!details.is_add && state_ != STATE_DISABLED) 374 if (!details.is_add && state_ != STATE_DISABLED)
373 SetState(STATE_NORMAL); 375 SetState(STATE_NORMAL);
374 } 376 }
375 377
376 void CustomButton::OnBlur() { 378 void CustomButton::OnBlur() {
377 if (IsHotTracked()) 379 if (IsHotTracked())
378 SetState(STATE_NORMAL); 380 SetState(STATE_NORMAL);
379 } 381 }
380 382
381 } // namespace views 383 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/button/custom_button_unittest.cc » ('j') | ui/views/controls/button/custom_button_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698