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

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

Issue 674163003: MenuButtons enter Hover state upon Tap Down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | ui/views/controls/button/menu_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/menu_button.cc
diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc
index f2b3852bb644d60444b92396f80bf70ba20207b5..cace30436f4dac9d42ec2d057cbeb5e9b3c130e1 100644
--- a/ui/views/controls/button/menu_button.cc
+++ b/ui/views/controls/button/menu_button.cc
@@ -9,6 +9,7 @@
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_switches_util.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/canvas.h"
@@ -205,12 +206,23 @@ void MenuButton::OnMouseMoved(const ui::MouseEvent& event) {
}
void MenuButton::OnGestureEvent(ui::GestureEvent* event) {
- if (state() != STATE_DISABLED && ShouldEnterPushedState(*event) &&
- !Activate()) {
- // When |Activate()| returns |false|, it means that a menu is shown and
- // has handled the gesture event. So, there is no need to further process
- // the gesture event here.
- return;
+ if (state() != STATE_DISABLED) {
+ if (switches::IsTouchFeedbackEnabled()) {
flackr 2014/10/27 17:51:27 Should this be done after line 220 so that the men
jonross 2014/10/27 18:51:39 Good call, that way any classes extending get the
+ if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
+ event->SetHandled();
flackr 2014/10/27 17:51:27 This doesn't prevent context menu generation, does
jonross 2014/10/27 18:51:39 No it does not, it just keeps this view as the eve
+ SetState(Button::STATE_HOVERED);
+ } else if (state() == Button::STATE_HOVERED &&
+ (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
+ event->type() == ui::ET_GESTURE_END)) {
+ SetState(Button::STATE_NORMAL);
+ }
+ }
+ if (ShouldEnterPushedState(*event) && !Activate()) {
+ // When |Activate()| returns |false|, it means that a menu is shown and
+ // has handled the gesture event. So, there is no need to further process
+ // the gesture event here.
+ return;
+ }
}
LabelButton::OnGestureEvent(event);
}
« no previous file with comments | « no previous file | ui/views/controls/button/menu_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698