8000 fix: correctly handle Alt+Key shortcuts by zcbenz · Pull Request #29445 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: correctly handle Alt+Key shortcuts #29445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shell/browser/ui/views/menu_bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ void MenuBar::SetAcceleratorVisibility(bool visible) {
}

MenuBar::View* MenuBar::FindAccelChild(base::char16 key) {
if (key == 0)
return nullptr;
for (auto* child : GetChildrenInZOrder()) {
if (static_cast<SubmenuButton*>(child)->accelerator() == key)
return child;
Expand Down
20 changes: 10 additions & 10 deletions shell/browser/ui/views/root_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ void RootView::HandleKeyEvent(const content::NativeWebKeyboardEvent& event) {

// Show the submenu when "Alt+Key" is pressed.
if (event.GetType() == blink::WebInputEvent::Type::kRawKeyDown &&
!IsAltKey(event) && IsAltModifier(event)) {
if (menu_bar_->HasAccelerator(event.windows_key_code)) {
if (!menu_bar_visible_) {
SetMenuBarVisibility(true);

View* focused_view = GetFocusManager()->GetFocusedView();
last_focused_view_tracker_->SetView(focused_view);
menu_bar_->RequestFocus();
}
event.windows_key_code >= ui::VKEY_A &&
event.windows_key_code <= ui::VKEY_Z && IsAltModifier(event) &&
menu_bar_->HasAccelerator(event.windows_key_code)) {
if (!menu_bar_visible_) {
SetMenuBarVisibility(true);

menu_bar_->ActivateAccelerator(event.windows_key_code);
View* focused_view = GetFocusManager()->GetFocusedView();
last_focused_view_tracker_->SetView(focused_view);
menu_bar_->RequestFocus();
}

menu_bar_->ActivateAccelerator(event.windows_key_code);
return;
}

Expand Down
0