diff --git a/samples/propgrid/sampleprops.cpp b/samples/propgrid/sampleprops.cpp index b1be4b1dfd..76a44ee1fe 100644 --- a/samples/propgrid/sampleprops.cpp +++ b/samples/propgrid/sampleprops.cpp @@ -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; +} diff --git a/samples/propgrid/sampleprops.h b/samples/propgrid/sampleprops.h index bc4cef7b49..889eb5de9d 100644 --- a/samples/propgrid/sampleprops.h +++ b/samples/propgrid/sampleprops.h @@ -127,6 +127,8 @@ public: virtual void GenerateValueAsString ( wxString& target, int prec, bool removeZeroes ) const; wxValidator* DoGetValidator() const wxOVERRIDE; + bool ValidateValue(wxVariant& value, + wxPGValidationInfo& validationInfo) const wxOVERRIDE; protected: wxString m_display; // Stores cache for displayed text