From 698700716b44531e57035bcb24d83653b1c11dd8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 5 Jan 2016 12:05:27 +0800 Subject: [PATCH] Show menu by clicking the menu button --- atom/browser/ui/views/menu_bar.cc | 18 +++++++----------- atom/browser/ui/views/menu_bar.h | 3 --- atom/browser/ui/views/menu_delegate.cc | 3 ++- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index 54b6957fa52f..ba0a542c1e8d 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -134,16 +134,6 @@ bool MenuBar::GetMenuButtonFromScreenPoint(const gfx::Point& point, return false; } -void MenuBar::RunMenu(views::MenuButton* button) { - int id = button->tag(); - ui::MenuModel::ItemType type = menu_model_->GetTypeAt(id); - if (type != ui::MenuModel::TYPE_SUBMENU) - return; - - MenuDelegate menu_delegate(this); - menu_delegate.RunMenu(menu_model_->GetSubmenuModelAt(id), button); -} - const char* MenuBar::GetClassName() const { return kViewClassName; } @@ -160,7 +150,13 @@ void MenuBar::OnMenuButtonClicked(views::View* source, return; views::MenuButton* button = static_cast(source); - RunMenu(button); + int id = button->tag(); + ui::MenuModel::ItemType type = menu_model_->GetTypeAt(id); + if (type != ui::MenuModel::TYPE_SUBMENU) + return; + + MenuDelegate menu_delegate(this); + menu_delegate.RunMenu(menu_model_->GetSubmenuModelAt(id), button); } } // namespace atom diff --git a/atom/browser/ui/views/menu_bar.h b/atom/browser/ui/views/menu_bar.h index 09d257c09732..9d77cfdf2a22 100644 --- a/atom/browser/ui/views/menu_bar.h +++ b/atom/browser/ui/views/menu_bar.h @@ -49,9 +49,6 @@ class MenuBar : public views::View, ui::MenuModel** menu_model, views::MenuButton** button); - // Shows the menu with |button|. - void RunMenu(views::MenuButton* button); - protected: // views::View: const char* GetClassName() const override; diff --git a/atom/browser/ui/views/menu_delegate.cc b/atom/browser/ui/views/menu_delegate.cc index 1c28cc10df39..8ef8bca72dee 100644 --- a/atom/browser/ui/views/menu_delegate.cc +++ b/atom/browser/ui/views/menu_delegate.cc @@ -121,7 +121,8 @@ void MenuDelegate::SwitchToSiblingMenu(views::MenuButton* button) { // nested message loop. content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, - base::Bind(&MenuBar::RunMenu, base::Unretained(menu_bar_), button)); + base::Bind(base::IgnoreResult(&views::MenuButton::Activate), + base::Unretained(button))); } } // namespace atom