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/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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 // Space sets button state to pushed. Enter clicks the button. This matches | 193 // Space sets button state to pushed. Enter clicks the button. This matches |
194 // the Windows native behavior of buttons, where Space clicks the button on | 194 // the Windows native behavior of buttons, where Space clicks the button on |
195 // KeyRelease and Enter clicks the button on KeyPressed. | 195 // KeyRelease and Enter clicks the button on KeyPressed. |
196 if (event.key_code() == ui::VKEY_SPACE) { | 196 if (event.key_code() == ui::VKEY_SPACE) { |
197 SetState(STATE_PRESSED); | 197 SetState(STATE_PRESSED); |
198 } else if (event.key_code() == ui::VKEY_RETURN) { | 198 } else if (event.key_code() == ui::VKEY_RETURN) { |
199 SetState(STATE_NORMAL); | 199 SetState(STATE_NORMAL); |
200 // TODO(beng): remove once NotifyClick takes ui::Event. | 200 // TODO(beng): remove once NotifyClick takes ui::Event. |
201 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, gfx::Point(), | 201 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, gfx::Point(), |
202 gfx::Point(), ui::EventTimeForNow(), | 202 gfx::Point(), ui::EventTimeForNow(), |
203 ui::EF_LEFT_MOUSE_BUTTON, | 203 ui::EF_LEFT_MOUSE_BUTTON | event.flags(), |
sadrul
2015/08/14 14:52:46
KeyEvent can have KeyEventFlags, which can mean di
Deepak
2015/08/17 06:32:51
Done.
| |
204 ui::EF_LEFT_MOUSE_BUTTON); | 204 ui::EF_LEFT_MOUSE_BUTTON); |
205 NotifyClick(synthetic_event); | 205 NotifyClick(synthetic_event); |
206 } else { | 206 } else { |
207 return false; | 207 return false; |
208 } | 208 } |
209 return true; | 209 return true; |
210 } | 210 } |
211 | 211 |
212 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { | 212 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { |
213 if ((state_ == STATE_DISABLED) || (event.key_code() != ui::VKEY_SPACE)) | 213 if ((state_ == STATE_DISABLED) || (event.key_code() != ui::VKEY_SPACE)) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 if (!details.is_add && state_ != STATE_DISABLED) | 349 if (!details.is_add && state_ != STATE_DISABLED) |
350 SetState(STATE_NORMAL); | 350 SetState(STATE_NORMAL); |
351 } | 351 } |
352 | 352 |
353 void CustomButton::OnBlur() { | 353 void CustomButton::OnBlur() { |
354 if (IsHotTracked()) | 354 if (IsHotTracked()) |
355 SetState(STATE_NORMAL); | 355 SetState(STATE_NORMAL); |
356 } | 356 } |
357 | 357 |
358 } // namespace views | 358 } // namespace views |
OLD | NEW |