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

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

Issue 1544803004: Fix accelerator handling for in-menu buttons in the app menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable the check on ChromeOS (again). Accelerator handling in extension popups is different betwee… 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/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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 event->StopPropagation(); 256 event->StopPropagation();
257 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL || 257 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
258 event->type() == ui::ET_GESTURE_END) { 258 event->type() == ui::ET_GESTURE_END) {
259 SetState(STATE_NORMAL); 259 SetState(STATE_NORMAL);
260 } 260 }
261 if (!event->handled()) 261 if (!event->handled())
262 Button::OnGestureEvent(event); 262 Button::OnGestureEvent(event);
263 } 263 }
264 264
265 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { 265 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) {
266 // Should only handle accelerators when active. However, only top level
267 // widgets can be active, so for child widgets check if they are focused
268 // instead.
269 if ((IsChildWidget() && !FocusInChildWidget()) ||
270 (!IsChildWidget() && !GetWidget()->IsActive())) {
271 return false;
272 }
273 SetState(STATE_NORMAL); 266 SetState(STATE_NORMAL);
274 // TODO(beng): remove once NotifyClick takes ui::Event. 267 // TODO(beng): remove once NotifyClick takes ui::Event.
275 ui::MouseEvent synthetic_event( 268 ui::MouseEvent synthetic_event(
276 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 269 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
277 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 270 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
278 NotifyClick(synthetic_event); 271 NotifyClick(synthetic_event);
279 return true; 272 return true;
280 } 273 }
281 274
282 void CustomButton::ShowContextMenu(const gfx::Point& p, 275 void CustomButton::ShowContextMenu(const gfx::Point& p,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 ink_drop_delegate()->OnAction(ink_drop_action_on_click_); 426 ink_drop_delegate()->OnAction(ink_drop_action_on_click_);
434 Button::NotifyClick(event); 427 Button::NotifyClick(event);
435 } 428 }
436 429
437 void CustomButton::OnClickCanceled(const ui::Event& event) { 430 void CustomButton::OnClickCanceled(const ui::Event& event) {
438 if (ink_drop_delegate()) 431 if (ink_drop_delegate())
439 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); 432 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
440 Button::OnClickCanceled(event); 433 Button::OnClickCanceled(event);
441 } 434 }
442 435
443 bool CustomButton::IsChildWidget() const {
444 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget();
445 }
446
447 bool CustomButton::FocusInChildWidget() const {
448 return GetWidget() &&
449 GetWidget()->GetRootView()->Contains(
450 GetFocusManager()->GetFocusedView());
451 }
452
453 } // namespace views 436 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698