diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index d2f2077151e8..2ae36bc36b3a 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -846,7 +846,7 @@ void NativeWindowViews::SetMenu(AtomMenuModel* menu_model) { if (!menu_bar_) { gfx::Size content_size = GetContentSize(); - menu_bar_.reset(new MenuBar); + menu_bar_.reset(new MenuBar(this)); menu_bar_->set_owned_by_client(); if (!menu_bar_autohide_) { diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index bd7c4fcac9db..f01edaa5b38e 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -47,9 +47,10 @@ void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight, } // namespace -MenuBar::MenuBar() +MenuBar::MenuBar(NativeWindow* window) : background_color_(kDefaultColor), - menu_model_(NULL) { + menu_model_(NULL), + window_(window) { UpdateMenuBarColor(); SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, 0, 0, 0)); @@ -142,6 +143,9 @@ void MenuBar::OnMenuButtonClicked(views::MenuButton* source, if (!menu_model_) return; + if (!window_->IsFocused()) + window_->Focus(true); + int id = source->tag(); AtomMenuModel::ItemType type = menu_model_->GetTypeAt(id); if (type != AtomMenuModel::TYPE_SUBMENU) { diff --git a/atom/browser/ui/views/menu_bar.h b/atom/browser/ui/views/menu_bar.h index 0f371ea0ce7f..761e31b98ea7 100644 --- a/atom/browser/ui/views/menu_bar.h +++ b/atom/browser/ui/views/menu_bar.h @@ -5,6 +5,7 @@ #ifndef ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_ #define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_ +#include "atom/browser/native_window.h" #include "atom/browser/ui/atom_menu_model.h" #include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/view.h" @@ -20,7 +21,7 @@ class MenuDelegate; class MenuBar : public views::View, public views::MenuButtonListener { public: - MenuBar(); + explicit MenuBar(NativeWindow* window); virtual ~MenuBar(); // Replaces current menu with a new one. @@ -66,6 +67,7 @@ class MenuBar : public views::View, SkColor hover_color_; #endif + NativeWindow* window_; AtomMenuModel* menu_model_; DISALLOW_COPY_AND_ASSIGN(MenuBar); diff --git a/atom/browser/ui/views/submenu_button.cc b/atom/browser/ui/views/submenu_button.cc index 2b3562022808..f7f954824f7b 100644 --- a/atom/browser/ui/views/submenu_button.cc +++ b/atom/browser/ui/views/submenu_button.cc @@ -52,10 +52,6 @@ SubmenuButton::SubmenuButton(const base::string16& title, SetHasInkDrop(true); set_ink_drop_base_color( color_utils::BlendTowardOppositeLuma(background_color_, 0x61)); - - set_request_focus_on_press(true); - SetFocusForPlatform(); - SetFocusPainter(nullptr); } SubmenuButton::~SubmenuButton() {