diff options
author | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 21:42:27 +0000 |
---|---|---|
committer | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 21:42:27 +0000 |
commit | 975c69bdeff4bcc245dee0bea30ff95923dd563a (patch) | |
tree | 9b2f59e2eb11bdb19087df574efd6847cd0f2024 /ui | |
parent | dd840a3fabf0def317a186433dff7cb7be20ea72 (diff) | |
download | chromium_src-975c69bdeff4bcc245dee0bea30ff95923dd563a.zip chromium_src-975c69bdeff4bcc245dee0bea30ff95923dd563a.tar.gz chromium_src-975c69bdeff4bcc245dee0bea30ff95923dd563a.tar.bz2 |
Ignore first release click in menus that are over the bounds.
BUG=100663
TEST=none
Review URL: http://codereview.chromium.org/9187079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/controls/menu/menu_controller.cc | 23 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_controller.h | 6 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_item_view.h | 5 |
3 files changed, 31 insertions, 3 deletions
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index 43a37b6..3408d2f 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -268,6 +268,11 @@ MenuItemView* MenuController::Run(Widget* parent, possible_drag_ = false; drag_in_progress_ = false; + // We need to drop the first mouse release event when the menu has been + // layed out over the bounds. + drop_first_release_event_ = + root->GetRequestedMenuPosition() == MenuItemView::POSITION_OVER_BOUNDS; + bool nested_menu = showing_; if (showing_) { // Only support nesting of blocking_run menus, nesting of @@ -405,6 +410,7 @@ void MenuController::OnMousePressed(SubmenuView* source, const MouseEvent& event) { if (!blocking_run_) return; + drop_first_release_event_ = false; DCHECK(!active_mouse_view_); @@ -518,6 +524,18 @@ void MenuController::OnMouseReleased(SubmenuView* source, if (!blocking_run_) return; + // We must ignore the first release event when it occured within the original + // bounds. + if (drop_first_release_event_ && event.flags() == ui::EF_LEFT_MOUSE_BUTTON) { + drop_first_release_event_ = false; + gfx::Point loc(event.location()); + View::ConvertPointToScreen(source->GetScrollViewContainer(), &loc); + DCHECK(!state_.initial_bounds.IsEmpty()); + if (state_.initial_bounds.Contains(loc)) + return; + } + drop_first_release_event_ = false; + DCHECK(state_.item); possible_drag_ = false; DCHECK(blocking_run_); @@ -1485,8 +1503,9 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize(); // Don't let the menu go too wide. - pref.set_width(std::min(pref.width(), - item->GetDelegate()->GetMaxWidthForMenu(item))); + if (item->actual_menu_position() != MenuItemView::POSITION_OVER_BOUNDS) + pref.set_width(std::min(pref.width(), + item->GetDelegate()->GetMaxWidthForMenu(item))); if (!state_.monitor_bounds.IsEmpty()) pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h index 59bdc8b..ceabd3b 100644 --- a/ui/views/controls/menu/menu_controller.h +++ b/ui/views/controls/menu/menu_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -430,6 +430,10 @@ class VIEWS_EXPORT MenuController : public MessageLoop::Dispatcher { // If true, we're showing. bool showing_; + // Is true for some menu types and only until the first mouse press or mouse + // release event occurs. + bool drop_first_release_event_; + // Indicates what to exit. ExitType exit_type_; diff --git a/ui/views/controls/menu/menu_item_view.h b/ui/views/controls/menu/menu_item_view.h index 99cfc53..dbc22f6 100644 --- a/ui/views/controls/menu/menu_item_view.h +++ b/ui/views/controls/menu/menu_item_view.h @@ -218,6 +218,11 @@ class VIEWS_EXPORT MenuItemView : public View { // Returns the type of this menu. const Type& GetType() const { return type_; } + // Returns the requested menu position. + const MenuPosition& GetRequestedMenuPosition() { + return requested_menu_position_; + } + // Sets whether this item is selected. This is invoked as the user moves // the mouse around the menu while open. void SetSelected(bool selected); |