From e228394656cd593f9b5ebaa907f842141ad45f4d Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Tue, 1 Apr 2025 18:57:26 +0200 Subject: [PATCH] [Input] Process key down event for some controls In #1424, the app event handler was disabling all key down events, preventing controls that depend on them to properly handle these. This was done to work around an issue on macOS where unhandled keyboard events would fire an audio alert. Since this breaks text controls, these changes check for the currently focused window and let the event propagate for text controls. Fixes #1434 --- src/wx/wxvbam.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 242765b9..3256db0b 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1412,6 +1413,17 @@ int wxvbamApp::FilterEvent(wxEvent& event) bool wxvbamApp::ProcessEvent(wxEvent& event) { if (event.GetEventType() == wxEVT_KEY_DOWN) { + // First, figure out if the focused window can process the key down event. + wxWindow* focused_window = wxWindow::FindFocus(); + wxTextCtrl* text_ctrl = wxDynamicCast(focused_window, wxTextCtrl); + if (text_ctrl) { + return wxApp::ProcessEvent(event); + } + wxSpinCtrl* spin_ctrl = wxDynamicCast(focused_window, wxSpinCtrl); + if (spin_ctrl) { + return wxApp::ProcessEvent(event); + } + // Mark the event as processed. This prevents wxWidgets from firing alerts on macOS. // See https://github.com/wxWidgets/wxWidgets/issues/25262 for details. return true;