From cb20b3453eba3b8efd1ef64e6c7f4d57a43ab76b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Dec 2013 00:19:15 +0000 Subject: [PATCH] Simplify wxTextValidator EVT_CHAR handler. Ignore the event by default to reduce the number of event.Skip() calls. No changes in the code behaviour. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75452 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/valtext.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index ede2f30275..70bf904009 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -302,11 +302,11 @@ void wxTextValidator::SetCharExcludes(const wxString& chars) void wxTextValidator::OnChar(wxKeyEvent& event) { + // Let the event propagate by default. + event.Skip(); + if (!m_validatorWindow) - { - event.Skip(); return; - } #if wxUSE_UNICODE // We only filter normal, printable characters. @@ -314,30 +314,22 @@ void wxTextValidator::OnChar(wxKeyEvent& event) #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) - { - event.Skip(); return; - } wxString str((wxUniChar)keyCode, 1); - if (!IsValid(str).empty()) - { - if ( !wxValidator::IsSilent() ) - wxBell(); - - // eat message + if (IsValid(str).empty()) return; - } - else - event.Skip(); + + if ( !wxValidator::IsSilent() ) + wxBell(); + + // eat message + event.Skip(false); }