Update linux menu overrides

This commit is contained in:
Brian R. Bondy 2016-04-30 19:56:28 -04:00 committed by Cheng Zhao
parent 0253aec0cd
commit f93fa53aea
4 changed files with 12 additions and 10 deletions

View file

@ -104,7 +104,7 @@ int MenuBar::GetAcceleratorIndex(base::char16 key) {
void MenuBar::ActivateAccelerator(base::char16 key) { void MenuBar::ActivateAccelerator(base::char16 key) {
int i = GetAcceleratorIndex(key); int i = GetAcceleratorIndex(key);
if (i != -1) if (i != -1)
static_cast<SubmenuButton*>(child_at(i))->Activate(); static_cast<SubmenuButton*>(child_at(i))->Activate(nullptr);
} }
int MenuBar::GetItemCount() const { int MenuBar::GetItemCount() const {
@ -141,22 +141,22 @@ const char* MenuBar::GetClassName() const {
void MenuBar::ButtonPressed(views::Button* sender, const ui::Event& event) { void MenuBar::ButtonPressed(views::Button* sender, const ui::Event& event) {
} }
void MenuBar::OnMenuButtonClicked(views::View* source, void MenuBar::OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point) { const gfx::Point& point,
const ui::Event* event) {
// Hide the accelerator when a submenu is activated. // Hide the accelerator when a submenu is activated.
SetAcceleratorVisibility(false); SetAcceleratorVisibility(false);
if (!menu_model_) if (!menu_model_)
return; return;
views::MenuButton* button = static_cast<views::MenuButton*>(source); int id = source->tag();
int id = button->tag();
ui::MenuModel::ItemType type = menu_model_->GetTypeAt(id); ui::MenuModel::ItemType type = menu_model_->GetTypeAt(id);
if (type != ui::MenuModel::TYPE_SUBMENU) if (type != ui::MenuModel::TYPE_SUBMENU)
return; return;
MenuDelegate menu_delegate(this); MenuDelegate menu_delegate(this);
menu_delegate.RunMenu(menu_model_->GetSubmenuModelAt(id), button); menu_delegate.RunMenu(menu_model_->GetSubmenuModelAt(id), source);
} }
} // namespace atom } // namespace atom

View file

@ -57,8 +57,10 @@ class MenuBar : public views::View,
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::MenuButtonListener: // views::MenuButtonListener:
void OnMenuButtonClicked(views::View* source, void OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point) override; const gfx::Point& point,
const ui::Event* event) override;
private: private:
SkColor background_color_; SkColor background_color_;

View file

@ -112,7 +112,7 @@ views::MenuItemView* MenuDelegate::GetSiblingMenu(
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
base::Bind(base::IgnoreResult(&views::MenuButton::Activate), base::Bind(base::IgnoreResult(&views::MenuButton::Activate),
base::Unretained(button))); base::Unretained(button), nullptr));
} }
return nullptr; return nullptr;

View file

@ -26,7 +26,7 @@ base::string16 FilterAccelerator(const base::string16& label) {
SubmenuButton::SubmenuButton(views::ButtonListener* listener, SubmenuButton::SubmenuButton(views::ButtonListener* listener,
const base::string16& title, const base::string16& title,
views::MenuButtonListener* menu_button_listener) views::MenuButtonListener* menu_button_listener)
: views::MenuButton(listener, FilterAccelerator(title), : views::MenuButton(FilterAccelerator(title),
menu_button_listener, false), menu_button_listener, false),
accelerator_(0), accelerator_(0),
show_underline_(false), show_underline_(false),