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

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

Issue 10546104: Make IsTriggerableEvent take Event objects and use it to verify whether tap events should trigger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass Event to ShouldEnterPushedState. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/menu/menu_delegate.h » ('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 897c772ff0b97e50e2ca4115ae8b636809b50a24..c45f573d2ef690da8223a15347f96889db0dbaae 100644
--- a/ui/views/controls/button/custom_button.cc
+++ b/ui/views/controls/button/custom_button.cc
@@ -197,7 +197,7 @@ ui::GestureStatus CustomButton::OnGestureEvent(const GestureEvent& event) {
if (state_ == BS_DISABLED)
return ui::GESTURE_STATUS_UNKNOWN;
- if (event.type() == ui::ET_GESTURE_TAP) {
+ if (event.type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(event)) {
// Set the button state to hot and start the animation fully faded in. The
// TAP_UP event issued immediately after will set the state to BS_NORMAL
// beginning the fade out animation. See http://crbug.com/131184.
@@ -205,7 +205,8 @@ ui::GestureStatus CustomButton::OnGestureEvent(const GestureEvent& event) {
hover_animation_->Reset(1.0);
NotifyClick(event);
return ui::GESTURE_STATUS_CONSUMED;
- } else if (event.type() == ui::ET_GESTURE_TAP_DOWN) {
+ } else if (event.type() == ui::ET_GESTURE_TAP_DOWN &&
+ ShouldEnterPushedState(event)) {
SetState(BS_PUSHED);
if (request_focus_on_press_)
RequestFocus();
@@ -282,11 +283,14 @@ CustomButton::CustomButton(ButtonListener* listener)
void CustomButton::StateChanged() {
}
-bool CustomButton::IsTriggerableEvent(const MouseEvent& event) {
- return (triggerable_event_flags_ & event.flags()) != 0;
+bool CustomButton::IsTriggerableEvent(const Event& event) {
+ return event.type() == ui::ET_GESTURE_TAP_DOWN ||
+ event.type() == ui::ET_GESTURE_TAP ||
+ (event.IsMouseEvent() &&
+ (triggerable_event_flags_ & event.flags()) != 0);
}
-bool CustomButton::ShouldEnterPushedState(const MouseEvent& event) {
+bool CustomButton::ShouldEnterPushedState(const Event& event) {
return IsTriggerableEvent(event);
}
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/menu/menu_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698