From 12d8f6919099a2c781ad022a3e93dbdb25369395 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 28 Jun 2017 10:29:49 +0200 Subject: [PATCH] Keep icon when text is changed Copied over code from the generic implementation to make things work properly - the icon got lost before. --- src/osx/cocoa/dataview.mm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 94793f1501..c8604fe180 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -3273,18 +3273,28 @@ bool wxDataViewIconTextRenderer::MacRender() return true; } -void -wxDataViewIconTextRenderer::OSXOnCellChanged(NSObject *value, +void wxDataViewIconTextRenderer::OSXOnCellChanged(NSObject *value, const wxDataViewItem& item, 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; - valueIconText << wxDataViewIconText(ObjectToString(value)); - + valueIconText << iconText; + if ( !Validate(valueIconText) ) return; - - wxDataViewModel *model = GetOwner()->GetOwner()->GetModel(); + model->ChangeValue(valueIconText, item, col); }