Skip to content

Commit bed5fdb

Browse files
authored
UI: Disable Ctrl+Q shortcut on non-macOS platforms to prevent accidental exits during gameplay (#1565)
1 parent 996539f commit bed5fdb

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/gui/MainWindow.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,15 +1448,23 @@ void MainWindow::OnKeyUp(wxKeyEvent& event)
14481448

14491449
void MainWindow::OnKeyDown(wxKeyEvent& event)
14501450
{
1451-
if ((event.AltDown() && event.GetKeyCode() == WXK_F4) ||
1452-
(event.CmdDown() && event.GetKeyCode() == 'Q'))
1453-
{
1454-
Close(true);
1455-
}
1456-
else
1457-
{
1458-
event.Skip();
1459-
}
1451+
#if defined(__APPLE__)
1452+
// On macOS, allow Cmd+Q to quit the application
1453+
if (event.CmdDown() && event.GetKeyCode() == 'Q')
1454+
{
1455+
Close(true);
1456+
}
1457+
#else
1458+
// On Windows/Linux, only Alt+F4 is allowed for quitting
1459+
if (event.AltDown() && event.GetKeyCode() == WXK_F4)
1460+
{
1461+
Close(true);
1462+
}
1463+
#endif
1464+
else
1465+
{
1466+
event.Skip();
1467+
}
14601468
}
14611469

14621470
void MainWindow::OnChar(wxKeyEvent& event)

0 commit comments

Comments
 (0)