Write shortcuts in the proper section (#1335)

Shortcuts were mistakenly written in `Keyboard/Keyboard` rather than in
the `Keyboard` section.
In addition, this properly fixes toggling checkable menu item options
via a shortcut.

Fixes #1334
This commit is contained in:
Fabrice de Gans 2024-09-11 22:48:06 -07:00 committed by GitHub
parent d619ee2bb1
commit 61f427dec1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -416,11 +416,9 @@ void update_shortcut_opts() {
// For keyboard shortcuts, it's easier to delete everything and start over. // For keyboard shortcuts, it's easier to delete everything and start over.
cfg->DeleteGroup("/Keyboard"); cfg->DeleteGroup("/Keyboard");
cfg->SetPath("/Keyboard");
for (const auto& iter : wxGetApp().bindings()->GetKeyboardConfiguration()) { for (const auto& iter : wxGetApp().bindings()->GetKeyboardConfiguration()) {
cfg->Write(iter.first, iter.second); cfg->Write(iter.first, iter.second);
} }
cfg->SetPath("/");
// For joypads, we just compare the strings. // For joypads, we just compare the strings.
bool game_bindings_changed = false; bool game_bindings_changed = false;

View File

@ -1372,8 +1372,19 @@ int wxvbamApp::FilterEvent(wxEvent& event)
return wxEventFilter::Event_Skip; return wxEventFilter::Event_Skip;
} }
// Queue the associated shortcut command. // Find the associated checkable menu item (if any).
wxCommandEvent* command_event = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, command_id); for (const cmditem& cmd_item : cmdtab) {
if (cmd_item.cmd_id == command_id) {
if (cmd_item.mi && cmd_item.mi->IsCheckable()) {
// Toggle the checkable menu item.
cmd_item.mi->Check(!cmd_item.mi->IsChecked());
}
break;
}
}
// Queue the associated shortcut command event.
wxCommandEvent* command_event = new wxCommandEvent(wxEVT_MENU, command_id);
command_event->SetEventObject(this); command_event->SetEventObject(this);
frame->GetEventHandler()->QueueEvent(command_event); frame->GetEventHandler()->QueueEvent(command_event);