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:
parent
8a9e5e5ac7
commit
b9ebffd832
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user