Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: views/controls/button/custom_button.cc

Issue 6685069: Disambiguate OnMouseCaptureLost from OnMouseReleased, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refinements, etc. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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/custom_button.h" 5 #include "views/controls/button/custom_button.h"
6 6
7 #include "ui/base/accessibility/accessible_view_state.h" 7 #include "ui/base/accessibility/accessible_view_state.h"
8 #include "ui/base/animation/throb_animation.h" 8 #include "ui/base/animation/throb_animation.h"
9 #include "ui/base/keycodes/keyboard_codes.h" 9 #include "ui/base/keycodes/keyboard_codes.h"
10 #include "views/screen.h" 10 #include "views/screen.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 bool CustomButton::OnMouseDragged(const MouseEvent& event) { 122 bool CustomButton::OnMouseDragged(const MouseEvent& event) {
123 if (state_ != BS_DISABLED) { 123 if (state_ != BS_DISABLED) {
124 if (HitTest(event.location())) 124 if (HitTest(event.location()))
125 SetState(ShouldEnterPushedState(event) ? BS_PUSHED : BS_HOT); 125 SetState(ShouldEnterPushedState(event) ? BS_PUSHED : BS_HOT);
126 else 126 else
127 SetState(BS_NORMAL); 127 SetState(BS_NORMAL);
128 } 128 }
129 return true; 129 return true;
130 } 130 }
131 131
132 void CustomButton::OnMouseReleased(const MouseEvent& event, bool canceled) { 132 void CustomButton::OnMouseReleased(const MouseEvent& event) {
133 // TODO(msw): Is this still true? Perhaps the InDrag() check is unnecessary.
msw 2011/03/17 23:28:51 Need guidance / testing; or leave as-is.
133 // Starting a drag results in a MouseReleased, we need to ignore it. 134 // Starting a drag results in a MouseReleased, we need to ignore it.
134 if ((state_ == BS_DISABLED) || InDrag()) 135 if ((state_ == BS_DISABLED) || InDrag())
135 return; 136 return;
136 137
137 if (!HitTest(event.location())) { 138 if (!HitTest(event.location())) {
138 SetState(BS_NORMAL); 139 SetState(BS_NORMAL);
139 return; 140 return;
140 } 141 }
141 142
142 SetState(BS_HOT); 143 SetState(BS_HOT);
143 if (!canceled && IsTriggerableEvent(event)) { 144 if (IsTriggerableEvent(event)) {
144 NotifyClick(event); 145 NotifyClick(event);
145 // NOTE: We may be deleted at this point (by the listener's notification 146 // NOTE: We may be deleted at this point (by the listener's notification
146 // handler). 147 // handler).
147 } 148 }
148 } 149 }
149 150
151 void CustomButton::OnMouseCaptureLost() {
152 // Starting a drag results in a MouseCaptureLost, we need to ignore it.
153 if (state_ != BS_DISABLED && !InDrag())
154 SetState(BS_NORMAL);
155 }
156
150 void CustomButton::OnMouseEntered(const MouseEvent& event) { 157 void CustomButton::OnMouseEntered(const MouseEvent& event) {
151 if (state_ != BS_DISABLED) 158 if (state_ != BS_DISABLED)
152 SetState(BS_HOT); 159 SetState(BS_HOT);
153 } 160 }
154 161
155 void CustomButton::OnMouseExited(const MouseEvent& event) { 162 void CustomButton::OnMouseExited(const MouseEvent& event) {
156 // Starting a drag results in a MouseExited, we need to ignore it. 163 // Starting a drag results in a MouseExited, we need to ignore it.
157 if (state_ != BS_DISABLED && !InDrag()) 164 if (state_ != BS_DISABLED && !InDrag())
158 SetState(BS_NORMAL); 165 SetState(BS_NORMAL);
159 } 166 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 bool CustomButton::IsFocusable() const { 283 bool CustomButton::IsFocusable() const {
277 return (state_ != BS_DISABLED) && View::IsFocusable(); 284 return (state_ != BS_DISABLED) && View::IsFocusable();
278 } 285 }
279 286
280 void CustomButton::OnBlur() { 287 void CustomButton::OnBlur() {
281 if (IsHotTracked()) 288 if (IsHotTracked())
282 SetState(BS_NORMAL); 289 SetState(BS_NORMAL);
283 } 290 }
284 291
285 } // namespace views 292 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698