From d9ba8f7fa17193ea088bdd59996d0ba2c8ff60e4 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 29 Jun 2017 11:23:49 +0200 Subject: [PATCH] Minimum code for triggering wxEVT_DATAVIEW_ITEM_START_EDITING event, see #479 The version with calling the base class resulted in always vetoing unless there was a custom renderer which had CreateEditorCtrl implemented. --- src/osx/cocoa/dataview.mm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index c8604fe180..6d0602e85e 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -1929,6 +1929,26 @@ outlineView:(NSOutlineView*)outlineView dvc->GetEventHandler()->ProcessEvent(event); } +-(BOOL) textShouldBeginEditing:(NSText*)textEditor +{ + currentlyEditedColumn = [self editedColumn]; + currentlyEditedRow = [self editedRow]; + + wxDataViewItem item = wxDataViewItemFromItem([self itemAtRow:currentlyEditedRow]); + + NSTableColumn* tableColumn = [[self tableColumns] objectAtIndex:currentlyEditedColumn]; + wxDataViewColumn* const col([static_cast(tableColumn) getColumnPointer]); + + wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); + // Before doing anything we send an event asking if editing of this item is really wanted. + wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_START_EDITING, dvc, col, item); + dvc->GetEventHandler()->ProcessEvent( event ); + if( !event.IsAllowed() ) + return NO; + + return YES; +} + -(void) textDidBeginEditing:(NSNotification*)notification { // this notification is only sent if the user started modifying the cell