diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 973b9e2113..1594894186 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -420,6 +420,16 @@ class WXDLLIMPEXP_PROPGRID wxPGValidationInfo { friend class wxPropertyGrid; public: + wxPGValidationInfo() + { + m_failureBehavior = 0; + m_isFailing = false; + } + + ~wxPGValidationInfo() + { + } + /** @return Returns failure behavior which is a combination of @ref propgrid_vfbflags. @@ -468,6 +478,9 @@ private: /** Validation failure behavior. Use wxPG_VFB_XXX flags. */ wxPGVFBFlags m_failureBehavior; + + // True when validation is currently failing. + bool m_isFailing; }; // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 9be3b2a3c6..937ada140e 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -2987,6 +2987,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue // m_validationInfo.m_failureBehavior = m_permanentValidationFailureBehavior; + m_validationInfo.m_isFailing = true; // // Variant list a special value that cannot be validated @@ -3119,6 +3120,8 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue pendingValue = value; } + m_validationInfo.m_isFailing = false; + return true; } @@ -3255,6 +3258,8 @@ void wxPropertyGrid::DoOnValidationFailureReset( wxPGProperty* property ) DrawItemAndChildren(property); } } + + m_validationInfo.m_isFailing = false; } // ----------------------------------------------------------------------- @@ -3271,6 +3276,9 @@ bool wxPropertyGrid::DoPropertyChanged( wxPGProperty* p, unsigned int selFlags ) m_inDoPropertyChanged = 1; + // If property's value is being changed, assume it is valid + OnValidationFailureReset(selected); + // Maybe need to update control wxASSERT( m_chgInfo_changedProperty != NULL ); @@ -3544,6 +3552,13 @@ void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event ) selected, wnd ) ) valueIsPending = true; + + // Mark value always as pending if validation is currently + // failing and value was not unspecified + if ( !valueIsPending && + !pendingValue.IsNull() && + m_validationInfo.m_isFailing ) + valueIsPending = true; } else {