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 NotifyClick(accelerator.ToKeyEvent()); |
322 ui::MouseEvent synthetic_event( | |
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); | |
326 return true; | 322 return true; |
327 } | 323 } |
328 | 324 |
329 bool CustomButton::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { | 325 bool CustomButton::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { |
330 // If this button is focused and the user presses space or enter, don't let | 326 // 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 | 327 // that be treated as an accelerator if there is a key click action |
332 // corresponding to it. | 328 // corresponding to it. |
333 return GetKeyClickActionForEvent(event) != KeyClickAction::CLICK_NONE; | 329 return GetKeyClickActionForEvent(event) != KeyClickAction::CLICK_NONE; |
334 } | 330 } |
335 | 331 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 GetInkDrop()->GetTargetInkDropState() == | 515 GetInkDrop()->GetTargetInkDropState() == |
520 views::InkDropState::ALTERNATE_ACTION_PENDING) { | 516 views::InkDropState::ALTERNATE_ACTION_PENDING) { |
521 AnimateInkDrop(views::InkDropState::HIDDEN, | 517 AnimateInkDrop(views::InkDropState::HIDDEN, |
522 ui::LocatedEvent::FromIfValid(&event)); | 518 ui::LocatedEvent::FromIfValid(&event)); |
523 } | 519 } |
524 } | 520 } |
525 Button::OnClickCanceled(event); | 521 Button::OnClickCanceled(event); |
526 } | 522 } |
527 | 523 |
528 } // namespace views | 524 } // namespace views |
OLD | NEW |