[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
This commit is contained in:
Fabrice de Gans 2025-04-01 18:57:26 +02:00
parent d5ac2a853b
commit e228394656
1 changed files with 12 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include <wx/progdlg.h>
#include <wx/protocol/http.h>
#include <wx/regex.h>
#include <wx/spinctrl.h>
#include <wx/sstream.h>
#include <wx/stdpaths.h>
#include <wx/string.h>
@ -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;