Set also wxPGEditor items while changing wxPGProperty choices

If we replace current set of choices when editor is active
we need also replace editor items.

Closes #18741.
This commit is contained in:
Artur Wieczorek 2020-05-01 19:28:44 +02:00
parent 8a9e5e5ac7
commit b9ebffd832

View File

@ -2091,19 +2091,30 @@ bool wxPGProperty::SetChoices( const wxPGChoices& choices )
// Property must be de-selected first (otherwise choices in // Property must be de-selected first (otherwise choices in
// the control would be de-synced with true choices) // the control would be de-synced with true choices)
wxPropertyGrid* pg = GetGrid(); wxPropertyGrid* pg = GetGrid();
if ( pg && pg->GetSelection() == this ) bool isSelected = pg && pg->GetSelection() == this;
if ( isSelected )
{
pg->ClearSelection(); pg->ClearSelection();
}
m_choices.Assign(choices); m_choices.Assign(choices);
if ( isSelected )
{ {
wxWindow* ctrl = pg->GetEditorControl();
if ( ctrl )
GetEditorClass()->SetItems(ctrl, m_choices.GetLabels());
}
// This may be needed to trigger some initialization // This may be needed to trigger some initialization
// (but don't do it if property is somewhat uninitialized) // (but don't do it if property is somewhat uninitialized)
wxVariant defVal = GetDefaultValue(); wxVariant defVal = GetDefaultValue();
if ( defVal.IsNull() ) if ( !defVal.IsNull() )
return false;
SetValue(defVal); SetValue(defVal);
if ( isSelected )
{
// Recreate editor
pg->DoSelectProperty(this, wxPG_SEL_FORCE);
} }
return true; return true;