From: Cheng Zhao Date: Mon, 18 Aug 2014 08:14:28 +0000 (+0800) Subject: A little cleanup. X-Git-Tag: v0.15.8~1^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=29abba824d2a7ee836ebd4fe843b206016b4ff92;p=electron.git A little cleanup. --- diff --git a/atom.gyp b/atom.gyp index e880d126..44e5e3e8 100644 --- a/atom.gyp +++ b/atom.gyp @@ -150,12 +150,12 @@ 'atom/browser/ui/views/global_menu_bar_x11.h', 'atom/browser/ui/views/menu_bar.cc', 'atom/browser/ui/views/menu_bar.h', - 'atom/browser/ui/views/submenu_button.cc', - 'atom/browser/ui/views/submenu_button.h', 'atom/browser/ui/views/menu_delegate.cc', 'atom/browser/ui/views/menu_delegate.h', 'atom/browser/ui/views/menu_layout.cc', 'atom/browser/ui/views/menu_layout.h', + 'atom/browser/ui/views/submenu_button.cc', + 'atom/browser/ui/views/submenu_button.h', 'atom/browser/ui/views/win_frame_view.cc', 'atom/browser/ui/views/win_frame_view.h', 'atom/browser/ui/win/notify_icon_host.cc', diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index a2702d36..efadac5c 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -572,22 +572,24 @@ void NativeWindowViews::HandleKeyboardEvent( const content::NativeWebKeyboardEvent& event) { keyboard_event_handler_->HandleKeyboardEvent(event, GetFocusManager()); - if (menu_bar_) { - // Toggle accelerator when "Alt" is pressed. - if (menu_bar_visible_ && IsAltKey(event)) - menu_bar_->SetAcceleratorVisibility( - event.type == blink::WebInputEvent::RawKeyDown); - - // Show the submenu when "Alt+Key" is pressed. - if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) && - IsAltModifier(event)) { - if (!menu_bar_visible_ && - (menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1)) { - SetMenuBarVisibility(true); - Layout(); - } - menu_bar_->ActivateAccelerator(event.windowsKeyCode); + if (!menu_bar_) + return; + + // Show accelerator when "Alt" is pressed. + if (menu_bar_visible_ && IsAltKey(event)) + menu_bar_->SetAcceleratorVisibility( + event.type == blink::WebInputEvent::RawKeyDown); + + // Show the submenu when "Alt+Key" is pressed. + if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) && + IsAltModifier(event)) { + if (!menu_bar_visible_ && + (menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1)) { + SetMenuBarVisibility(true); + Layout(); } + menu_bar_->ActivateAccelerator(event.windowsKeyCode); + return; } if (!menu_bar_autohide_)