Merge pull request #7468 from electron/focus-window-when-menu-is-clicked

Focus window when menu button is pressed
This commit is contained in:
Cheng Zhao 2016-10-04 14:22:49 +09:00 committed by GitHub
commit cf050ff9e2
4 changed files with 7 additions and 14 deletions

View file

@ -63,8 +63,7 @@ void MenuBar::SetMenu(AtomMenuModel* model) {
RemoveAllChildViews(true);
for (int i = 0; i < model->GetItemCount(); ++i) {
SubmenuButton* button = new SubmenuButton(this,
model->GetLabelAt(i),
SubmenuButton* button = new SubmenuButton(model->GetLabelAt(i),
this,
background_color_);
button->set_tag(i);
@ -134,9 +133,6 @@ const char* MenuBar::GetClassName() const {
return kViewClassName;
}
void MenuBar::ButtonPressed(views::Button* sender, const ui::Event& event) {
}
void MenuBar::OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point,
const ui::Event* event) {

View file

@ -6,7 +6,6 @@
#define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
#include "atom/browser/ui/atom_menu_model.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/view.h"
@ -19,7 +18,6 @@ namespace atom {
class MenuDelegate;
class MenuBar : public views::View,
public views::ButtonListener,
public views::MenuButtonListener {
public:
MenuBar();
@ -50,9 +48,6 @@ class MenuBar : public views::View,
// views::View:
const char* GetClassName() const override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::MenuButtonListener:
void OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point,

View file

@ -26,8 +26,7 @@ base::string16 FilterAccelerator(const base::string16& label) {
} // namespace
SubmenuButton::SubmenuButton(views::ButtonListener* listener,
const base::string16& title,
SubmenuButton::SubmenuButton(const base::string16& title,
views::MenuButtonListener* menu_button_listener,
const SkColor& background_color)
: views::MenuButton(FilterAccelerator(title),
@ -53,6 +52,10 @@ SubmenuButton::SubmenuButton(views::ButtonListener* listener,
SetHasInkDrop(true);
set_ink_drop_base_color(
color_utils::BlendTowardOppositeLuma(background_color_, 0x61));
set_request_focus_on_press(true);
SetFocusForPlatform();
SetFocusPainter(nullptr);
}
SubmenuButton::~SubmenuButton() {

View file

@ -13,8 +13,7 @@ namespace atom {
// Special button that used by menu bar to show submenus.
class SubmenuButton : public views::MenuButton {
public:
SubmenuButton(views::ButtonListener* listener,
const base::string16& title,
SubmenuButton(const base::string16& title,
views::MenuButtonListener* menu_button_listener,
const SkColor& background_color);
virtual ~SubmenuButton();