diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 90bb1c2aaf..085fa2a7c7 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -2501,10 +2501,6 @@ public: corresponding event. Is @NULL otherwise (for keyboard activation). Mouse coordinates are adjusted to be relative to the cell. - @note Currently support for this method is not implemented in the - native macOS version of the control, i.e. it will be never called - there. - @since 2.9.3 @note Do not confuse this method with item activation in wxDataViewCtrl diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index e13521b042..78c153c088 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -1677,10 +1677,35 @@ outlineView:(NSOutlineView*)outlineView // and setDoubleAction: seems to be wrong as this action message is always // sent whether the cell is editable or not wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); + wxDataViewModel * const model = dvc->GetModel(); const wxDataViewItem item = wxDataViewItemFromItem([self itemAtRow:[self clickedRow]]); + + const NSInteger col = [self clickedColumn]; + wxDataViewColumn* const dvCol = implementation->GetColumn(col); + + // Check if we need to activate a custom renderer first. + if ( wxDataViewCustomRenderer* const + renderer = wxDynamicCast(dvCol->GetRenderer(), wxDataViewCustomRenderer) ) + { + if ( renderer->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE && + model->IsEnabled(item, dvCol->GetModelColumn()) ) + { + const wxRect rect = implementation->GetRectangle(item, dvCol); + + wxMouseEvent mouseEvent(wxEVT_LEFT_DCLICK); + wxPoint pos = dvc->ScreenToClient(wxGetMousePosition()); + pos -= rect.GetPosition(); + mouseEvent.m_x = pos.x; + mouseEvent.m_y = pos.y; + + renderer->ActivateCell(rect, model, item, col, &mouseEvent); + } + } + + // And then send the ACTIVATED event in any case. wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_ACTIVATED, dvc, item); - event.SetColumn( [self clickedColumn] ); + event.SetColumn(col); dvc->GetEventHandler()->ProcessEvent(event); }