OSX: Add value to EVT_DATAVIEW_ITEM_EDITING_DONE (PR #26367)

12 views
Skip to first unread message

RobertRoeb

unread,
Apr 9, 2026, 2:16:16 PM (2 days ago) Apr 9
to wx-...@googlegroups.com, Subscribed
  • The value only seems to be reported in OSXCellChanged so defer sending the event until then (unless it was cancelled).
  • This was recently reported as a bug, but I cannot find the report anymore

You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26367

Commit Summary

  • c1f758a Add value to EVT_DATAVIEW_ITEM_EDITING_DONE

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26367@github.com>

VZ

unread,
Apr 9, 2026, 2:58:47 PM (2 days ago) Apr 9
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Thanks for the fix, I think this bug was recently reported by @hwiesmann on the mailing list.

If there is no other way to fix it, I guess we should do it like this even if this likely means that the order of events may be different in wxOSX and the other ports.

I also wonder if we really need to do this for anything but string values, it looks like they're the only ones for which we want to have the new value in the handler. And if it were done like this, the changes could be made much smaller by calling OSXSendEditingDoneEvent() from -outlineView:outlineView:setObjectValue:forTableColumn:byItem: itself.


In src/osx/cocoa/dataview.mm:

> @@ -1831,7 +1831,7 @@ -(void) outlineViewSelectionDidChange:(NSNotification*)notification
     dvc->GetEventHandler()->ProcessEvent(event);
 }
 
--(void) sendEditingDoneEvent:(BOOL)isCancelled
+-(void) sendEditingDoneEvent:(BOOL)isCancelled withNotification:(NSNotification*)notification

The newly added notification parameter doesn't seem to be used, am I missing something?


In include/wx/osx/dvrenderer.h:

> @@ -79,6 +79,10 @@ class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
     void OSXUpdateAlignment();
 
 #if wxOSX_USE_COCOA
+    bool m_callEditingDoneOnCellChange;

Minor but it's better to initialize members in their declarations in the new code:

⬇️ Suggested change
-    bool m_callEditingDoneOnCellChange;
+    bool m_callEditingDoneOnCellChange = false;

In src/osx/cocoa/dataview.mm:

> +      m_NativeDataPtr(nullptr),
+      m_callEditingDoneOnCellChange(false)
⬇️ Suggested change
-      m_NativeDataPtr(nullptr),
-      m_callEditingDoneOnCellChange(false)
+      m_NativeDataPtr(nullptr)

In src/osx/cocoa/dataview.mm:

>      if ( !Validate(value) )
         return;
 
     wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
     model->ChangeValue(value, item, col);
 }
 
+void wxDataViewRenderer::OSXSendEditingDoneEvent( const wxDataViewItem &item, const wxVariant &value )
+{
+    if (m_callEditingDoneOnCellChange)
+    {
+        wxDataViewColumn *column = GetOwner();
+        wxDataViewCtrl *dvc = column->GetOwner();
+        wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EDITING_DONE, dvc, column, item);
+        event.SetValue( value );
+        dvc->GetEventHandler()->ProcessEvent(event);
+
+        m_callEditingDoneOnCellChange = false;

Call me paranoid, but I'd rather do it as the first statement in the if branch, before dispatching the event — just in case it could somehow result in reentering this function.


In include/wx/osx/dvrenderer.h:

> @@ -79,6 +79,10 @@ class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
     void OSXUpdateAlignment();
 
 #if wxOSX_USE_COCOA
+    bool m_callEditingDoneOnCellChange;
+    void OSXCallEditingDoneOnCellChange() { m_callEditingDoneOnCellChange = true; }
+    void OSXSendEditingDoneEvent( const wxDataViewItem &item, const wxVariant &value );

I'd like to either rename this function or at least add a comment explaining that it's not unconditional, i.e.

⬇️ Suggested change
-    void OSXSendEditingDoneEvent( const wxDataViewItem &item, const wxVariant &value );
+    void OSXSendEditingDoneEventIfPending( const wxDataViewItem &item, const wxVariant &value );


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26367/review/4084688095@github.com>

Reply all
Reply to author
Forward
0 new messages