OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/button/custom_button.h" | 5 #include "views/controls/button/custom_button.h" |
6 | 6 |
7 #include "app/throb_animation.h" | 7 #include "app/throb_animation.h" |
8 #include "base/keyboard_codes.h" | 8 #include "base/keyboard_codes.h" |
9 #include "views/screen.h" | 9 #include "views/screen.h" |
10 | 10 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return false; | 190 return false; |
191 | 191 |
192 // Space sets button state to pushed. Enter clicks the button. This matches | 192 // Space sets button state to pushed. Enter clicks the button. This matches |
193 // the Windows native behavior of buttons, where Space clicks the button on | 193 // the Windows native behavior of buttons, where Space clicks the button on |
194 // KeyRelease and Enter clicks the button on KeyPressed. | 194 // KeyRelease and Enter clicks the button on KeyPressed. |
195 if (e.GetKeyCode() == base::VKEY_SPACE) { | 195 if (e.GetKeyCode() == base::VKEY_SPACE) { |
196 SetState(BS_PUSHED); | 196 SetState(BS_PUSHED); |
197 } else if (e.GetKeyCode() == base::VKEY_RETURN) { | 197 } else if (e.GetKeyCode() == base::VKEY_RETURN) { |
198 SetState(BS_NORMAL); | 198 SetState(BS_NORMAL); |
199 NotifyClick(e); | 199 NotifyClick(e); |
| 200 } else { |
| 201 return false; |
200 } | 202 } |
201 return true; | 203 return true; |
202 } | 204 } |
203 | 205 |
204 bool CustomButton::OnKeyReleased(const KeyEvent& e) { | 206 bool CustomButton::OnKeyReleased(const KeyEvent& e) { |
205 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != base::VKEY_SPACE)) | 207 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != base::VKEY_SPACE)) |
206 return false; | 208 return false; |
207 | 209 |
208 SetState(BS_NORMAL); | 210 SetState(BS_NORMAL); |
209 NotifyClick(e); | 211 NotifyClick(e); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 255 |
254 void CustomButton::AnimationProgressed(const Animation* animation) { | 256 void CustomButton::AnimationProgressed(const Animation* animation) { |
255 SchedulePaint(); | 257 SchedulePaint(); |
256 } | 258 } |
257 | 259 |
258 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { | 260 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { |
259 return IsTriggerableEvent(e); | 261 return IsTriggerableEvent(e); |
260 } | 262 } |
261 | 263 |
262 } // namespace views | 264 } // namespace views |
OLD | NEW |