views: Pressing "Alt+Key" should bring up the menu bar.

This commit is contained in:
Cheng Zhao 2014-08-18 14:52:44 +08:00
parent ba41634ad6
commit a230daa998
3 changed files with 25 additions and 9 deletions

View file

@ -572,16 +572,22 @@ void NativeWindowViews::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
keyboard_event_handler_->HandleKeyboardEvent(event, GetFocusManager());
if (menu_bar_ && menu_bar_visible_) {
if (menu_bar_) {
// Toggle accelerator when "Alt" is pressed.
if (IsAltKey(event))
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))
IsAltModifier(event)) {
if (!menu_bar_visible_ &&
(menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1)) {
SetMenuBarVisibility(true);
Layout();
}
menu_bar_->ActivateAccelerator(event.windowsKeyCode);
}
}
if (!menu_bar_autohide_)