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/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
6 | 6 |
7 #include "ui/accessibility/ax_node_data.h" | 7 #include "ui/accessibility/ax_node_data.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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL || | 311 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL || |
312 event->type() == ui::ET_GESTURE_END) { | 312 event->type() == ui::ET_GESTURE_END) { |
313 SetState(STATE_NORMAL); | 313 SetState(STATE_NORMAL); |
314 } | 314 } |
315 if (!event->handled()) | 315 if (!event->handled()) |
316 Button::OnGestureEvent(event); | 316 Button::OnGestureEvent(event); |
317 } | 317 } |
318 | 318 |
319 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { | 319 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { |
320 SetState(STATE_NORMAL); | 320 SetState(STATE_NORMAL); |
321 // TODO(beng): remove once NotifyClick takes ui::Event. | 321 ui::Event synthetic_event(ui::ET_UNKNOWN, ui::EventTimeForNow(), |
sky
2017/06/22 00:55:48
Given we create an accelerator from a KeyEvent, wo
bruthig
2017/07/10 18:03:13
Done.
| |
322 ui::MouseEvent synthetic_event( | 322 ui::EF_IS_SYNTHESIZED); |
323 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), | |
324 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | |
325 NotifyClick(synthetic_event); | 323 NotifyClick(synthetic_event); |
326 return true; | 324 return true; |
327 } | 325 } |
328 | 326 |
329 bool CustomButton::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { | 327 bool CustomButton::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { |
330 // If this button is focused and the user presses space or enter, don't let | 328 // If this button is focused and the user presses space or enter, don't let |
331 // that be treated as an accelerator if there is a key click action | 329 // that be treated as an accelerator if there is a key click action |
332 // corresponding to it. | 330 // corresponding to it. |
333 return GetKeyClickActionForEvent(event) != KeyClickAction::CLICK_NONE; | 331 return GetKeyClickActionForEvent(event) != KeyClickAction::CLICK_NONE; |
334 } | 332 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 GetInkDrop()->GetTargetInkDropState() == | 517 GetInkDrop()->GetTargetInkDropState() == |
520 views::InkDropState::ALTERNATE_ACTION_PENDING) { | 518 views::InkDropState::ALTERNATE_ACTION_PENDING) { |
521 AnimateInkDrop(views::InkDropState::HIDDEN, | 519 AnimateInkDrop(views::InkDropState::HIDDEN, |
522 ui::LocatedEvent::FromIfValid(&event)); | 520 ui::LocatedEvent::FromIfValid(&event)); |
523 } | 521 } |
524 } | 522 } |
525 Button::OnClickCanceled(event); | 523 Button::OnClickCanceled(event); |
526 } | 524 } |
527 | 525 |
528 } // namespace views | 526 } // namespace views |
OLD | NEW |