Keep icon when text is changed

Copied over code from the generic implementation to make things work properly - the icon got lost before.
This commit is contained in:
Stefan Csomor
2017-06-28 10:29:49 +02:00
parent 8d78887a22
commit 12d8f69190

View File

@@ -3273,18 +3273,28 @@ bool wxDataViewIconTextRenderer::MacRender()
return true; return true;
} }
void void wxDataViewIconTextRenderer::OSXOnCellChanged(NSObject *value,
wxDataViewIconTextRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item, const wxDataViewItem& item,
unsigned col) unsigned col)
{ {
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
// The icon can't be edited so get its old value and reuse it.
wxVariant valueOld;
model->GetValue(valueOld, item, col);
wxDataViewIconText iconText;
iconText << valueOld;
// But replace the text with the value entered by user.
iconText.SetText(ObjectToString(value));
wxVariant valueIconText; wxVariant valueIconText;
valueIconText << wxDataViewIconText(ObjectToString(value)); valueIconText << iconText;
if ( !Validate(valueIconText) ) if ( !Validate(valueIconText) )
return; return;
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(valueIconText, item, col); model->ChangeValue(valueIconText, item, col);
} }