From aff918ab1d4984286fb3cc11406dafceeadd7903 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Dec 2013 00:19:12 +0000 Subject: [PATCH] Handle Unicode keys correctly in wxTextValidator. Don't allow entering arbitrary Unicode keys in wxTextValidator limited to digits only, for example. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75451 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/valtext.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index 1d62a70c8a..ede2f30275 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -308,10 +308,20 @@ void wxTextValidator::OnChar(wxKeyEvent& event) return; } +#if wxUSE_UNICODE + // We only filter normal, printable characters. + int keyCode = event.GetUnicodeKey(); +#else // !wxUSE_UNICODE int keyCode = event.GetKeyCode(); + if (keyCode > WXK_START) + { + event.Skip(); + return; + } +#endif // wxUSE_UNICODE/!wxUSE_UNICODE // we don't filter special keys and delete - if (keyCode < WXK_SPACE || keyCode == WXK_DELETE || keyCode >= WXK_START) + if (keyCode < WXK_SPACE || keyCode == WXK_DELETE) { event.Skip(); return;