diff --git a/docs/changes.txt b/docs/changes.txt index 780544c4f4..4349a6a570 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -258,6 +258,7 @@ wxGTK: - Dramatically optimize adding many items to wxChoice (Ian McInerney, #23443). - Improve document wxGLCanvas::CreateSurface() (Dan Gudmundsson, #23366). - Fix loading WebKit2 extension when using wxWebView (Scott Talbert, #23497). +- Fix editing cells without values in wxDataViewCtrl (#23523). wxMSW: diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 9d75ccc8a1..e080f1ffcb 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -3224,10 +3224,18 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column), wxDataViewModel *wx_model = tree_model->internal->GetDataViewModel(); - cell->GtkSetCurrentItem(item); - // Cells without values shouldn't be rendered at all. - const bool visible = cell->PrepareForItem(wx_model, item, column); + const bool visible = wx_model->HasValue(item, column); + if ( visible ) + { + cell->GtkSetCurrentItem(item); + + // Ignore the return value of PrepareForItem() here, if it returns + // false because GetValue() didn't return anything, we still want to + // keep this cell visible, as otherwise it wouldn't be possible to edit + // it neither, and we do want to allow editing empty cells. + cell->PrepareForItem(wx_model, item, column); + } wxGtkValue gvalue( G_TYPE_BOOLEAN ); g_value_set_boolean( gvalue, visible );