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
This commit is contained in:
@@ -302,11 +302,11 @@ void wxTextValidator::SetCharExcludes(const wxString& chars)
|
|||||||
|
|
||||||
void wxTextValidator::OnChar(wxKeyEvent& event)
|
void wxTextValidator::OnChar(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
|
// Let the event propagate by default.
|
||||||
|
event.Skip();
|
||||||
|
|
||||||
if (!m_validatorWindow)
|
if (!m_validatorWindow)
|
||||||
{
|
|
||||||
event.Skip();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
// We only filter normal, printable characters.
|
// We only filter normal, printable characters.
|
||||||
@@ -314,30 +314,22 @@ void wxTextValidator::OnChar(wxKeyEvent& event)
|
|||||||
#else // !wxUSE_UNICODE
|
#else // !wxUSE_UNICODE
|
||||||
int keyCode = event.GetKeyCode();
|
int keyCode = event.GetKeyCode();
|
||||||
if (keyCode > WXK_START)
|
if (keyCode > WXK_START)
|
||||||
{
|
|
||||||
event.Skip();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||||
|
|
||||||
// we don't filter special keys and delete
|
// we don't filter special keys and delete
|
||||||
if (keyCode < WXK_SPACE || keyCode == WXK_DELETE)
|
if (keyCode < WXK_SPACE || keyCode == WXK_DELETE)
|
||||||
{
|
|
||||||
event.Skip();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
wxString str((wxUniChar)keyCode, 1);
|
wxString str((wxUniChar)keyCode, 1);
|
||||||
if (!IsValid(str).empty())
|
if (IsValid(str).empty())
|
||||||
{
|
|
||||||
if ( !wxValidator::IsSilent() )
|
|
||||||
wxBell();
|
|
||||||
|
|
||||||
// eat message
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else
|
if ( !wxValidator::IsSilent() )
|
||||||
event.Skip();
|
wxBell();
|
||||||
|
|
||||||
|
// eat message
|
||||||
|
event.Skip(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user