| 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_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
| 8 #include "ui/base/material_design/material_design_controller.h" | 8 #include "ui/base/material_design/material_design_controller.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 bool CustomButton::OnKeyPressed(const ui::KeyEvent& event) { | 262 bool CustomButton::OnKeyPressed(const ui::KeyEvent& event) { |
| 263 if (state_ == STATE_DISABLED) | 263 if (state_ == STATE_DISABLED) |
| 264 return false; | 264 return false; |
| 265 | 265 |
| 266 // Space sets button state to pushed. Enter clicks the button. This matches | 266 // Space sets button state to pushed. Enter clicks the button. This matches |
| 267 // the Windows native behavior of buttons, where Space clicks the button on | 267 // the Windows native behavior of buttons, where Space clicks the button on |
| 268 // KeyRelease and Enter clicks the button on KeyPressed. | 268 // KeyRelease and Enter clicks the button on KeyPressed. |
| 269 if (event.key_code() == ui::VKEY_SPACE) { | 269 if (event.key_code() == ui::VKEY_SPACE) { |
| 270 SetState(STATE_PRESSED); | 270 SetState(STATE_PRESSED); |
| 271 if (ink_drop_delegate_ && |
| 272 ink_drop_delegate_->GetTargetInkDropState() != |
| 273 views::InkDropState::ACTION_PENDING) |
| 274 ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING); |
| 271 } else if (event.key_code() == ui::VKEY_RETURN) { | 275 } else if (event.key_code() == ui::VKEY_RETURN) { |
| 272 SetState(STATE_NORMAL); | 276 SetState(STATE_NORMAL); |
| 273 NotifyClick(event); | 277 NotifyClick(event); |
| 274 } else { | 278 } else { |
| 275 return false; | 279 return false; |
| 276 } | 280 } |
| 277 return true; | 281 return true; |
| 278 } | 282 } |
| 279 | 283 |
| 280 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { | 284 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 Button::NotifyClick(event); | 512 Button::NotifyClick(event); |
| 509 } | 513 } |
| 510 | 514 |
| 511 void CustomButton::OnClickCanceled(const ui::Event& event) { | 515 void CustomButton::OnClickCanceled(const ui::Event& event) { |
| 512 if (ink_drop_delegate()) | 516 if (ink_drop_delegate()) |
| 513 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | 517 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| 514 Button::OnClickCanceled(event); | 518 Button::OnClickCanceled(event); |
| 515 } | 519 } |
| 516 | 520 |
| 517 } // namespace views | 521 } // namespace views |
| OLD | NEW |