Fix pause toggle keybinding when unmuting.

We use the same event for both keybinding and `Emulation` > `Pause`
actions. The issue here is that the menu item is checkable, meaning
that you toggle its value and then run the handler.

The handler checks the value of the menu item `Emulation` > `Pause`,
and toggle the game pause accordingly. Such thing does not happen when
using the keybinding. Hence, it did not toggle the pause as expected.

- Related to #454.
This commit is contained in:
Edênis Freindorfer Azevedo 2019-06-28 23:02:10 -03:00 committed by Rafael Kitover
parent 8b8efa1b2d
commit fa77010f23
2 changed files with 15 additions and 2 deletions

View File

@ -1353,7 +1353,20 @@ EVT_HANDLER(wxID_EXIT, "Exit")
// Emulation menu
EVT_HANDLER(Pause, "Pause (toggle)")
{
GetMenuOptionBool("Pause", paused);
bool menuPress;
GetMenuOptionBool("Pause", menuPress);
if (paused == menuPress)
{
// used accelerator
paused = !paused;
SetMenuOption("Pause", paused ? 1 : 0);
}
else
{
// used menu item
paused = menuPress;
}
if (paused)
panel->Pause();

View File

@ -818,7 +818,7 @@ void MainFrame::OnSize(wxSizeEvent& event)
int MainFrame::FilterEvent(wxEvent& event)
{
if (!IsPaused() && event.GetEventType() == wxEVT_KEY_DOWN)
if (event.GetEventType() == wxEVT_KEY_DOWN)
{
wxKeyEvent& ke = (wxKeyEvent&)event;
int keyCode = ke.GetKeyCode();