https://github.com/wxWidgets/wxWidgets/pull/26367
(2 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@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.
> @@ -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;
> + m_NativeDataPtr(nullptr), + m_callEditingDoneOnCellChange(false)⬇️ Suggested change
- m_NativeDataPtr(nullptr), - m_callEditingDoneOnCellChange(false) + m_NativeDataPtr(nullptr)
> 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.![]()