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

Unified Diff: ui/views/controls/button/custom_button.cc

Issue 1411523009: Adds OnClickCanceled callback to views::Button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds NotifyReleasedWithoutClick callback to views::Button (comments) Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/button.cc ('k') | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/custom_button.cc
diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc
index 66d9b2c1788b9b2d37e92c25eca1df27c527d796..bfc356c595d5577d1ee7e8e73347e5a8a0f68ed1 100644
--- a/ui/views/controls/button/custom_button.cc
+++ b/ui/views/controls/button/custom_button.cc
@@ -137,16 +137,16 @@ const char* CustomButton::GetClassName() const {
}
bool CustomButton::OnMousePressed(const ui::MouseEvent& event) {
- if (state_ != STATE_DISABLED) {
- if (ShouldEnterPushedState(event) && HitTestPoint(event.location()))
- SetState(STATE_PRESSED);
- if (request_focus_on_press_)
- RequestFocus();
- if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) {
- NotifyClick(event);
- // NOTE: We may be deleted at this point (by the listener's notification
- // handler).
- }
+ if (state_ == STATE_DISABLED)
+ return true;
+ if (ShouldEnterPushedState(event) && HitTestPoint(event.location()))
+ SetState(STATE_PRESSED);
+ if (request_focus_on_press_)
+ RequestFocus();
+ if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) {
+ NotifyClick(event);
+ // NOTE: We may be deleted at this point (by the listener's notification
+ // handler).
}
return true;
}
@@ -162,20 +162,21 @@ bool CustomButton::OnMouseDragged(const ui::MouseEvent& event) {
}
void CustomButton::OnMouseReleased(const ui::MouseEvent& event) {
- if (state_ == STATE_DISABLED)
- return;
-
- if (!HitTestPoint(event.location())) {
- SetState(STATE_NORMAL);
- return;
- }
-
- SetState(STATE_HOVERED);
- if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_RELEASE) {
- NotifyClick(event);
- // NOTE: We may be deleted at this point (by the listener's notification
- // handler).
+ if (state_ != STATE_DISABLED) {
+ if (!HitTestPoint(event.location())) {
+ SetState(STATE_NORMAL);
+ } else {
+ SetState(STATE_HOVERED);
+ if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_RELEASE) {
+ NotifyClick(event);
+ // NOTE: We may be deleted at this point (by the listener's notification
+ // handler).
+ return;
+ }
+ }
}
+ if (notify_action_ == NOTIFY_ON_RELEASE)
+ OnClickCanceled(event);
}
void CustomButton::OnMouseCaptureLost() {
« no previous file with comments | « ui/views/controls/button/button.cc ('k') | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698