Implement more detailed validation of wxArrayDoubleProperty in propgrid sample.

Added wxArrayDoubleProperty::ValidateValue() method checks if pending value is of proper type (wxArrayDouble). Pending value of improper type is used to signal that invalid numeric value was entered into the edit field.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78513 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek
2015-02-17 17:36:00 +00:00
parent f9876c519e
commit ac1d0a3a9d
2 changed files with 18 additions and 3 deletions

View File

@@ -608,7 +608,6 @@ bool wxArrayDoubleProperty::StringToValue( wxVariant& variant, const wxString& t
// If token was invalid, exit the loop now
if ( !token.ToDouble(&tval) )
{
wxLogDebug( _("\"%s\" is not a floating-point number."), token.c_str() );
ok = false;
break;
}
@@ -618,10 +617,12 @@ bool wxArrayDoubleProperty::StringToValue( wxVariant& variant, const wxString& t
WX_PG_TOKENIZER1_END()
// When invalid token found don't change anything
// When invalid token found signal the error
// by returning pending value of non-wxArrayDouble type.
if ( !ok )
{
return false;
variant = (long)0;
return true;
}
if ( !(wxArrayDoubleRefFromVariant(m_value) == new_array) )
@@ -665,3 +666,15 @@ wxValidator* wxArrayDoubleProperty::DoGetValidator() const
return NULL;
#endif
}
bool wxArrayDoubleProperty::ValidateValue(wxVariant& value,
wxPGValidationInfo& validationInfo) const
{
if (!value.IsType("wxArrayDouble"))
{
validationInfo.SetFailureMessage(_("At least one element is not a valid floating-point number."));
return false;
}
return true;
}