From bed5fdb1951814633a3eaea0445bcddb62b63df9 Mon Sep 17 00:00:00 2001 From: Issa <32466950+gamersalpha@users.noreply.github.com> Date: Tue, 13 May 2025 03:38:11 +0200 Subject: [PATCH] UI: Disable Ctrl+Q shortcut on non-macOS platforms to prevent accidental exits during gameplay (#1565) --- src/gui/MainWindow.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index f2a5a2fa..2f63b460 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1448,15 +1448,23 @@ void MainWindow::OnKeyUp(wxKeyEvent& event) void MainWindow::OnKeyDown(wxKeyEvent& event) { - if ((event.AltDown() && event.GetKeyCode() == WXK_F4) || - (event.CmdDown() && event.GetKeyCode() == 'Q')) - { - Close(true); - } - else - { - event.Skip(); - } +#if defined(__APPLE__) + // On macOS, allow Cmd+Q to quit the application + if (event.CmdDown() && event.GetKeyCode() == 'Q') + { + Close(true); + } +#else + // On Windows/Linux, only Alt+F4 is allowed for quitting + if (event.AltDown() && event.GetKeyCode() == WXK_F4) + { + Close(true); + } +#endif + else + { + event.Skip(); + } } void MainWindow::OnChar(wxKeyEvent& event)