diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-08 14:46:36 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-08 14:46:36 +0000 |
commit | 2e1f49096ed49419de8c740a20ab106c14ffbf44 (patch) | |
tree | 787ff8465a8c859105a38b155ce89057c13ea8ce | |
parent | 30039e6ec600f1ac2a34e0881f4c0c10ee6f80cd (diff) | |
download | chromium_src-2e1f49096ed49419de8c740a20ab106c14ffbf44.zip chromium_src-2e1f49096ed49419de8c740a20ab106c14ffbf44.tar.gz chromium_src-2e1f49096ed49419de8c740a20ab106c14ffbf44.tar.bz2 |
This patch is from Andrew Brampton <me@bramp.net>.
This patches allows menu items in PopUpMenus to be clicked with the right mouse
button.
menu.cc controls the web content popup menus, and some others
chrome_menu{.cc,.h} controls popup menu on the chrome, for example right
clicking on a tab.
BUG=718
TEST=Bring up any menu (wrench/document) and right click on one of the items. This should select the item. Try the same with any of the bookmark menus.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1838 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 3 | ||||
-rw-r--r-- | chrome/views/chrome_menu.cc | 11 | ||||
-rw-r--r-- | chrome/views/chrome_menu.h | 8 | ||||
-rw-r--r-- | chrome/views/menu.cc | 2 |
5 files changed, 17 insertions, 8 deletions
@@ -4,3 +4,4 @@ Google Inc. Alex Scheele <alexscheele@gmail.com> Seo Sanghyeon <sanxiyn@gmail.com> +Andrew Brampton <me@bramp.net>
\ No newline at end of file diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 191aa04..d7fbabf 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -488,7 +488,7 @@ class MenuRunner : public ChromeViews::MenuDelegate, return result; } - virtual void ShowContextMenu(MenuItemView* source, + virtual bool ShowContextMenu(MenuItemView* source, int id, int x, int y, @@ -498,6 +498,7 @@ class MenuRunner : public ChromeViews::MenuDelegate, new BookmarkBarContextMenuController(view_, menu_id_to_node_map_[id])); context_menu_->RunMenuAt(x, y); context_menu_.reset(NULL); + return true; } virtual void DropMenuClosed(MenuItemView* menu) { diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index 360f6c1..33452cd 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -1785,9 +1785,14 @@ void MenuController::OnMouseReleased(SubmenuView* source, SetSelection(pending_state_.item, open_submenu, true); CPoint loc(event.GetX(), event.GetY()); View::ConvertPointToScreen(source->GetScrollViewContainer(), &loc); - part.menu->GetDelegate()->ShowContextMenu( - part.menu, part.menu->GetCommand(), loc.x, loc.y, true); - } else if (!part.is_scroll() && part.menu && !part.menu->HasSubmenu()) { + + // If we open a context menu just return now + if (part.menu->GetDelegate()->ShowContextMenu( + part.menu, part.menu->GetCommand(), loc.x, loc.y, true)) + return; + } + + if (!part.is_scroll() && part.menu && !part.menu->HasSubmenu()) { if (part.menu->GetDelegate()->IsTriggerableEvent(event)) { Accept(part.menu, event.GetFlags()); return; diff --git a/chrome/views/chrome_menu.h b/chrome/views/chrome_menu.h index a017b3d..05cce11 100644 --- a/chrome/views/chrome_menu.h +++ b/chrome/views/chrome_menu.h @@ -72,11 +72,13 @@ class MenuDelegate : Controller { // If this is not the result of a mouse gesture x/y is the recommended // location to display the content menu at. In either case, x/y is in // screen coordinates. - virtual void ShowContextMenu(MenuItemView* source, + // Returns true if a context menu was displayed, otherwise false + virtual bool ShowContextMenu(MenuItemView* source, int id, int x, int y, bool is_mouse_gesture) { + return false; } // Controller @@ -101,9 +103,9 @@ class MenuDelegate : Controller { } // Returns true if the specified mouse event is one the user can use - // to trigger, or accept, the mouse. Defaults to only left mouse buttons. + // to trigger, or accept, the mouse. Defaults to left or right mouse buttons. virtual bool IsTriggerableEvent(const MouseEvent& e) { - return e.IsLeftMouseButton(); + return e.IsLeftMouseButton() || e.IsRightMouseButton(); } // Invoked to determine if drops can be accepted for a submenu. This is diff --git a/chrome/views/menu.cc b/chrome/views/menu.cc index 89e7593..93185d6a 100644 --- a/chrome/views/menu.cc +++ b/chrome/views/menu.cc @@ -546,7 +546,7 @@ void Menu::RunMenuAt(int x, int y) { // Show the menu. Blocks until the menu is dismissed or an item is chosen. UINT flags = - GetTPMAlignFlags() | TPM_LEFTBUTTON | TPM_RETURNCMD | TPM_RECURSE; + GetTPMAlignFlags() | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE; is_menu_visible_ = true; DCHECK(owner_); // In order for context menus on menus to work, the context menu needs to |