Show menu by clicking the menu button
This commit is contained in:
parent
43bfce26a7
commit
698700716b
3 changed files with 9 additions and 15 deletions
|
@ -134,16 +134,6 @@ bool MenuBar::GetMenuButtonFromScreenPoint(const gfx::Point& point,
|
||||||
return false;
|
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 {
|
const char* MenuBar::GetClassName() const {
|
||||||
return kViewClassName;
|
return kViewClassName;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +150,13 @@ void MenuBar::OnMenuButtonClicked(views::View* source,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
views::MenuButton* button = static_cast<views::MenuButton*>(source);
|
views::MenuButton* button = static_cast<views::MenuButton*>(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
|
} // namespace atom
|
||||||
|
|
|
@ -49,9 +49,6 @@ class MenuBar : public views::View,
|
||||||
ui::MenuModel** menu_model,
|
ui::MenuModel** menu_model,
|
||||||
views::MenuButton** button);
|
views::MenuButton** button);
|
||||||
|
|
||||||
// Shows the menu with |button|.
|
|
||||||
void RunMenu(views::MenuButton* button);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// views::View:
|
// views::View:
|
||||||
const char* GetClassName() const override;
|
const char* GetClassName() const override;
|
||||||
|
|
|
@ -121,7 +121,8 @@ void MenuDelegate::SwitchToSiblingMenu(views::MenuButton* button) {
|
||||||
// nested message loop.
|
// nested message loop.
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
content::BrowserThread::UI, FROM_HERE,
|
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
|
} // namespace atom
|
||||||
|
|
Loading…
Reference in a new issue