OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/radio_button.h" | 5 #include "views/controls/button/radio_button.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
9 #include "views/widget/root_view.h" | 9 #include "views/widget/root_view.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 return NULL; | 81 return NULL; |
82 } | 82 } |
83 | 83 |
84 bool RadioButton::IsGroupFocusTraversable() const { | 84 bool RadioButton::IsGroupFocusTraversable() const { |
85 // When focusing a radio button with tab/shift+tab, only the selected button | 85 // When focusing a radio button with tab/shift+tab, only the selected button |
86 // from the group should be focused. | 86 // from the group should be focused. |
87 return false; | 87 return false; |
88 } | 88 } |
89 | 89 |
90 void RadioButton::OnMouseReleased(const MouseEvent& event, bool canceled) { | 90 void RadioButton::OnMouseReleased(const MouseEvent& event) { |
91 native_wrapper_->SetPushed(false); | |
92 // Set the checked state to true only if we are unchecked, since we can't | 91 // Set the checked state to true only if we are unchecked, since we can't |
93 // be toggled on and off like a checkbox. | 92 // be toggled on and off like a checkbox. |
94 if (!checked() && !canceled && HitTestLabel(event)) | 93 if (!checked() && HitTestLabel(event)) |
95 SetChecked(true); | 94 SetChecked(true); |
96 | 95 |
| 96 OnMouseCaptureLost(); |
| 97 } |
| 98 |
| 99 void RadioButton::OnMouseCaptureLost() { |
| 100 native_wrapper_->SetPushed(false); |
97 ButtonPressed(); | 101 ButtonPressed(); |
98 } | 102 } |
99 | 103 |
100 std::string RadioButton::GetClassName() const { | 104 std::string RadioButton::GetClassName() const { |
101 return kViewClassName; | 105 return kViewClassName; |
102 } | 106 } |
103 | 107 |
104 //////////////////////////////////////////////////////////////////////////////// | 108 //////////////////////////////////////////////////////////////////////////////// |
105 // RadioButton, NativeButton overrides: | 109 // RadioButton, NativeButton overrides: |
106 | 110 |
107 NativeButtonWrapper* RadioButton::CreateWrapper() { | 111 NativeButtonWrapper* RadioButton::CreateWrapper() { |
108 NativeButtonWrapper* native_wrapper = | 112 NativeButtonWrapper* native_wrapper = |
109 NativeButtonWrapper::CreateRadioButtonWrapper(this); | 113 NativeButtonWrapper::CreateRadioButtonWrapper(this); |
110 native_wrapper->UpdateLabel(); | 114 native_wrapper->UpdateLabel(); |
111 native_wrapper->UpdateChecked(); | 115 native_wrapper->UpdateChecked(); |
112 return native_wrapper; | 116 return native_wrapper; |
113 } | 117 } |
114 | 118 |
115 } // namespace views | 119 } // namespace views |
OLD | NEW |