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

Unified Diff: views/controls/button/button_dropdown.cc

Issue 159838: Right clicking the back and forward buttons is buggy. A single right click op... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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 | « views/controls/button/button_dropdown.h ('k') | views/controls/button/custom_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/button/button_dropdown.cc
===================================================================
--- views/controls/button/button_dropdown.cc (revision 22914)
+++ views/controls/button/button_dropdown.cc (working copy)
@@ -50,14 +50,14 @@
MessageLoop::current()->PostDelayedTask(FROM_HERE,
show_menu_factory_.NewRunnableMethod(&ButtonDropDown::ShowDropDownMenu,
GetWidget()->GetNativeView()),
- kMenuTimerDelay);
+ kMenuTimerDelay);
}
-
return ImageButton::OnMousePressed(e);
}
void ButtonDropDown::OnMouseReleased(const MouseEvent& e, bool canceled) {
- ImageButton::OnMouseReleased(e, canceled);
+ if (e.IsLeftMouseButton() || e.IsRightMouseButton() && !HitTest(e.location()))
+ ImageButton::OnMouseReleased(e, canceled);
if (canceled)
return;
@@ -67,13 +67,10 @@
if (IsEnabled() && e.IsRightMouseButton() && HitTest(e.location())) {
show_menu_factory_.RevokeAll();
- // Make the button look depressed while the menu is open.
- // NOTE: SetState() schedules a paint, but it won't occur until after the
- // context menu message loop has terminated, so we PaintNow() to
- // update the appearance synchronously.
- SetState(BS_PUSHED);
- PaintNow();
ShowDropDownMenu(GetWidget()->GetNativeView());
+ // Set the state back to normal after the drop down menu is closed.
+ if (state_ != BS_DISABLED)
+ SetState(BS_NORMAL);
}
}
@@ -93,6 +90,14 @@
return result;
}
+void ButtonDropDown::OnMouseExited(const MouseEvent& e) {
+ // Starting a drag results in a MouseExited, we need to ignore it.
+ // A right click release triggers an exit event. We want to
+ // remain in a PUSHED state until the drop down menu closes.
+ if (state_ != BS_DISABLED && !InDrag() && state_ != BS_PUSHED)
+ SetState(BS_NORMAL);
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// ButtonDropDown - Menu functions
@@ -111,6 +116,13 @@
SetState(BS_HOT);
}
+bool ButtonDropDown::ShouldEnterPushedState(const MouseEvent& e) {
+ // Enter PUSHED state on press with Left or Right mouse button. Remain
+ // in this state while the context menu is open.
+ return ((MouseEvent::EF_LEFT_BUTTON_DOWN |
+ MouseEvent::EF_RIGHT_BUTTON_DOWN) & e.GetFlags()) != 0;
+}
+
void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) {
if (model_) {
gfx::Rect lb = GetLocalBounds(true);
« no previous file with comments | « views/controls/button/button_dropdown.h ('k') | views/controls/button/custom_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698