diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 21:54:44 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 21:54:44 +0000 |
commit | 8c30313c62097a718190a9df00e681a75e47d42f (patch) | |
tree | 12c57430411f0859746190ab50a5b1ec42c1f469 /chrome | |
parent | 6840158fdaef4b2ece5ee8248907454fb4b7a84f (diff) | |
download | chromium_src-8c30313c62097a718190a9df00e681a75e47d42f.zip chromium_src-8c30313c62097a718190a9df00e681a75e47d42f.tar.gz chromium_src-8c30313c62097a718190a9df00e681a75e47d42f.tar.bz2 |
Fixes bug in showing context menu for buttons. In particular because
we weren't resetting state before showing the context menu it was
possible for the button to stay in a HOT state even though it isn't.
BUG=2620
TEST=see bug
Review URL: http://codereview.chromium.org/10835
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/views/base_button.cc | 11 | ||||
-rw-r--r-- | chrome/views/base_button.h | 3 | ||||
-rw-r--r-- | chrome/views/menu_button.cc | 23 | ||||
-rw-r--r-- | chrome/views/view.cc | 3 |
4 files changed, 25 insertions, 15 deletions
diff --git a/chrome/views/base_button.cc b/chrome/views/base_button.cc index 7fc4772..6424f90 100644 --- a/chrome/views/base_button.cc +++ b/chrome/views/base_button.cc @@ -236,6 +236,17 @@ bool BaseButton::OnKeyReleased(const KeyEvent& e) { return false; } +void BaseButton::ShowContextMenu(int x, int y, bool is_mouse_gesture) { + if (GetContextMenuController()) { + // We're about to show the context menu. Showing the context menu likely + // means we won't get a mouse exited and reset state. Reset it now to be + // sure. + if (GetState() != BS_DISABLED) + SetState(BS_NORMAL); + View::ShowContextMenu(x, y, is_mouse_gesture); + } +} + bool BaseButton::AcceleratorPressed(const Accelerator& accelerator) { if (enabled_) { SetState(BS_NORMAL); diff --git a/chrome/views/base_button.h b/chrome/views/base_button.h index b943f9f..d9ed2e3 100644 --- a/chrome/views/base_button.h +++ b/chrome/views/base_button.h @@ -86,6 +86,8 @@ class BaseButton : public View, virtual void OnMouseExited(const MouseEvent& e); virtual bool OnKeyPressed(const KeyEvent& e); virtual bool OnKeyReleased(const KeyEvent& e); + // Overriden to reset state then invoke super's implementation. + virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); class ButtonListener { public: @@ -182,4 +184,3 @@ class BaseButton : public View, } // namespace views #endif // CHROME_VIEWS_BASE_BUTTON_H__ - diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc index a723e87..59b0aa2 100644 --- a/chrome/views/menu_button.cc +++ b/chrome/views/menu_button.cc @@ -170,7 +170,6 @@ bool MenuButton::Activate() { // or selected an item) and we will inevitably refresh the hot state // in the event the mouse _is_ over the view. SetState(BS_NORMAL); - SchedulePaint(); // We must return false here so that the RootView does not get stuck // sending all mouse pressed events to us instead of the appropriate @@ -217,6 +216,17 @@ bool MenuButton::OnKeyReleased(const KeyEvent& e) { return true; } +// The reason we override View::OnMouseExited is because we get this event when +// we display the menu. If we don't override this method then +// BaseButton::OnMouseExited will get the event and will set the button's state +// to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will +// cause the button to appear depressed while the menu is displayed. +void MenuButton::OnMouseExited(const MouseEvent& event) { + if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) { + SetState(BS_NORMAL); + } +} + //////////////////////////////////////////////////////////////////////////////// // // MenuButton - accessibility @@ -245,15 +255,4 @@ bool MenuButton::GetAccessibleState(VARIANT* state) { return true; } -// The reason we override View::OnMouseExited is because we get this event when -// we display the menu. If we don't override this method then -// BaseButton::OnMouseExited will get the event and will set the button's state -// to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will -// cause the button to appear depressed while the menu is displayed. -void MenuButton::OnMouseExited(const MouseEvent& event) { - if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) { - SetState(BS_NORMAL); - } -} - } // namespace views diff --git a/chrome/views/view.cc b/chrome/views/view.cc index 9925ff4..0ab209a 100644 --- a/chrome/views/view.cc +++ b/chrome/views/view.cc @@ -537,8 +537,7 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) { ConvertPointToScreen(this, &location); ContextMenuController* context_menu_controller = context_menu_controller_; OnMouseReleased(e, canceled); - context_menu_controller_->ShowContextMenu(this, location.x(), location.y(), - true); + ShowContextMenu(location.x(), location.y(), true); } else { OnMouseReleased(e, canceled); } |