Make wxFILTER_INCLUDE_LIST in wxTextValidator actually usable.

Only check for its violation once the full text is entered as otherwise
nothing could ever be entered when it was used.

Closes #15778.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75768 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-02-02 01:15:45 +00:00
parent 9319b2649c
commit eebf3f12d5
2 changed files with 8 additions and 6 deletions

View File

@@ -595,6 +595,7 @@ All (GUI):
all commands without saving (Neil Chittenden). all commands without saving (Neil Chittenden).
- Fix crash when Destroy()-ing a TLW with non-TLW parent. - Fix crash when Destroy()-ing a TLW with non-TLW parent.
- Fix crash in wxAuiToolBar::GetToolBarFits(). - Fix crash in wxAuiToolBar::GetToolBarFits().
- Make wxFILTER_INCLUDE_LIST in wxTextValidator actually usable.
- Make wxHTML more efficient when displaying large tables (Kinaou Hervé). - Make wxHTML more efficient when displaying large tables (Kinaou Hervé).
- Prevent wxGrid rows/columns from becoming too small on double click. - Prevent wxGrid rows/columns from becoming too small on double click.

View File

@@ -156,10 +156,15 @@ bool wxTextValidator::Validate(wxWindow *parent)
wxString val(text->GetValue()); wxString val(text->GetValue());
wxString errormsg; wxString errormsg;
// We can only do some kinds of validation once the input is complete, so
// check for them here:
if ( HasFlag(wxFILTER_EMPTY) && val.empty() ) if ( HasFlag(wxFILTER_EMPTY) && val.empty() )
{
errormsg = _("Required information entry is empty."); errormsg = _("Required information entry is empty.");
} else if ( HasFlag(wxFILTER_INCLUDE_LIST) && m_includes.Index(val) == wxNOT_FOUND )
errormsg = wxString::Format(_("'%s' is invalid"), val);
else if ( HasFlag(wxFILTER_EXCLUDE_LIST) && m_excludes.Index(val) != wxNOT_FOUND )
errormsg = wxString::Format(_("'%s' is invalid"), val);
else if ( !(errormsg = IsValid(val)).empty() ) else if ( !(errormsg = IsValid(val)).empty() )
{ {
// NB: this format string should always contain exactly one '%s' // NB: this format string should always contain exactly one '%s'
@@ -245,12 +250,8 @@ wxString wxTextValidator::IsValid(const wxString& val) const
return _("'%s' should only contain digits."); return _("'%s' should only contain digits.");
if ( HasFlag(wxFILTER_NUMERIC) && !wxIsNumeric(val) ) if ( HasFlag(wxFILTER_NUMERIC) && !wxIsNumeric(val) )
return _("'%s' should be numeric."); return _("'%s' should be numeric.");
if ( HasFlag(wxFILTER_INCLUDE_LIST) && m_includes.Index(val) == wxNOT_FOUND )
return _("'%s' is invalid");
if ( HasFlag(wxFILTER_INCLUDE_CHAR_LIST) && !ContainsOnlyIncludedCharacters(val) ) if ( HasFlag(wxFILTER_INCLUDE_CHAR_LIST) && !ContainsOnlyIncludedCharacters(val) )
return _("'%s' is invalid"); return _("'%s' is invalid");
if ( HasFlag(wxFILTER_EXCLUDE_LIST) && m_excludes.Index(val) != wxNOT_FOUND )
return _("'%s' is invalid");
if ( HasFlag(wxFILTER_EXCLUDE_CHAR_LIST) && ContainsExcludedCharacters(val) ) if ( HasFlag(wxFILTER_EXCLUDE_CHAR_LIST) && ContainsExcludedCharacters(val) )
return _("'%s' is invalid"); return _("'%s' is invalid");