Send wxEVT_DATAVIEW_ITEM_EDITING_DONE for all renderers in wxGTK
Previously this event was not sent for the standard renderers, such as wxDataViewTextRenderer, at all in wxGTK because the base class FinishEditing() class didn't do anything if m_editorCtrl was null, as it was always the case for non-custom renderers. Fix this by refactoring the base class code in yet another way and extracting the part which can be reused by both the generic and GTK implementation in a new DoHandleEditingDone() function and call it from wxGTK code. Finally, check "editing-canceled" property to also correctly generate the event with IsEditCancelled() returning true when editing is canceled by e.g. pressing Esc in a standard renderer too. And, as a final bonus, this makes the (just introduced) slightly artificial DoFinishOrCancelEditing() unnecessary, so it can be removed, without reintroducing any code duplication. See #17835.
This commit is contained in:
@@ -1932,9 +1932,24 @@ bool wxGtkDataViewModelNotifier::Cleared()
|
||||
// ---------------------------------------------------------
|
||||
|
||||
static void
|
||||
wxgtk_cell_editable_editing_done( GtkCellEditable *WXUNUSED(editable),
|
||||
wxgtk_cell_editable_editing_done( GtkCellEditable *editable,
|
||||
wxDataViewRenderer *wxrenderer )
|
||||
{
|
||||
// "editing-cancelled" property is documented as being new since 2.20 in
|
||||
// GtkCellEditable, but seems to have existed basically forever (since GTK+
|
||||
// 1.3 days) in GtkCellRendererText, so try to use it in any case.
|
||||
if ( g_object_class_find_property(G_OBJECT_GET_CLASS(editable),
|
||||
"editing-canceled") )
|
||||
{
|
||||
gboolean wasCancelled;
|
||||
g_object_get(editable, "editing-canceled", &wasCancelled, NULL);
|
||||
if ( wasCancelled )
|
||||
{
|
||||
wxrenderer->CancelEditing();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxrenderer->FinishEditing();
|
||||
}
|
||||
|
||||
@@ -2164,15 +2179,10 @@ wxDataViewRenderer::GtkGetValueFromString(const wxString& str) const
|
||||
void
|
||||
wxDataViewRenderer::GtkOnTextEdited(const char *itempath, const wxString& str)
|
||||
{
|
||||
m_item = wxDataViewItem(GetView()->GTKPathToItem(wxGtkTreePath(itempath)));
|
||||
|
||||
wxVariant value(GtkGetValueFromString(str));
|
||||
if (!Validate( value ))
|
||||
return;
|
||||
|
||||
wxDataViewItem
|
||||
item(GetOwner()->GetOwner()->GTKPathToItem(wxGtkTreePath(itempath)));
|
||||
|
||||
wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
|
||||
model->ChangeValue( value, item, GetOwner()->GetModelColumn() );
|
||||
DoHandleEditingDone(&value);
|
||||
}
|
||||
|
||||
void wxDataViewRenderer::SetAttr(const wxDataViewItemAttr& WXUNUSED(attr))
|
||||
|
Reference in New Issue
Block a user