From f6e8a8177b9a788143af50b495e95bc51ae57452 Mon Sep 17 00:00:00 2001 From: Brendan Hagan Date: Wed, 20 Jul 2022 21:44:40 -0400 Subject: [PATCH] fix: correct unicode text entry behavior (fixes twanvl#121) GetKeyCode doesn't handle unicode, so it returns 0 for cyrillic (and other) characters, which was getting rejected as invalid input. I'm assuming this broke on some wxWidgets upgrade, as the MSE code for this hasn't changed in over a decade? --- src/gui/value/text.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index 47b35968..cb705b27 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -482,8 +482,15 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { } } return true; - default: - #ifdef __WXMSW__ + default: + #if defined UNICODE + // I think in theory this works because the UnicodeKey is intended to be only character values. + // See the following link for pretty much an exact example of this type of handling. + // https://docs.wxwidgets.org/3.0/classwx_key_event.html#a3dccc5a254770931e5d8066ef47e7fb0 + // Most of the special keys (<32) are handled in the case structure above anyways. + // I tried to replicate the Numpad issue mentioned below, but couldn't - so unclear if that's still relevant. + if (ev.GetUnicodeKey() >= WXK_SPACE) { + #elif defined __WXMSW__ if (ev.GetKeyCode() >= _(' ') && ev.GetKeyCode() == (int)ev.GetRawKeyCode()) { // This check is need, otherwise pressing a key, say "0" on the numpad produces "a0" // (don't ask me why)