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:
Vadim Zeitlin
2018-02-05 01:05:16 +01:00
parent a00b8dec8b
commit 33cbefd739
3 changed files with 58 additions and 48 deletions

View File

@@ -247,6 +247,12 @@ protected:
const wxDataViewItem& item,
unsigned column) const;
// Validates the given value (if it is non-null) and sends (in any case)
// ITEM_EDITING_DONE event and, finally, updates the model with the value
// (f it is valid, of course) if the event wasn't vetoed.
bool DoHandleEditingDone(wxVariant* value);
wxString m_variantType;
wxDataViewColumn *m_owner;
wxWeakRef<wxWindow> m_editorCtrl;
@@ -259,9 +265,6 @@ protected:
wxDataViewCtrl* GetView() const;
private:
// Common part of {Cancel,Finish}Editing().
bool DoFinishOrCancelEditing(bool cancelled);
// Called from {Called,Finish}Editing() and dtor to cleanup m_editorCtrl
void DestroyEditControl();