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/trunk@75449 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
2d3a1aab74
commit
39edfa27a2
@ -14,3 +14,7 @@ All (GUI):
|
||||
- XRC handler for wxAuiToolBar added (Kinaou Hervé).
|
||||
- Add wxHtmlWindow::SetDefaultHTMLCursor() (Jeff A. Marr).
|
||||
- Add default ctor and Create() to wxContextHelpButton (Hanmac).
|
||||
|
||||
wxMSW:
|
||||
|
||||
- Make wxFILTER_INCLUDE_LIST in wxTextValidator actually usable.
|
||||
|
@ -156,10 +156,15 @@ bool wxTextValidator::Validate(wxWindow *parent)
|
||||
wxString val(text->GetValue());
|
||||
|
||||
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() )
|
||||
{
|
||||
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() )
|
||||
{
|
||||
// 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.");
|
||||
if ( HasFlag(wxFILTER_NUMERIC) && !wxIsNumeric(val) )
|
||||
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) )
|
||||
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) )
|
||||
return _("'%s' is invalid");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user