Call wxDataViewCustomRenderer::ActivateCell() in Mac version too

Do this for consistency with the other ports.

Closes #17746.
This commit is contained in:
Vadim Zeitlin
2019-09-17 00:04:04 +02:00
parent 3a9869b4c4
commit b9338b6130
2 changed files with 26 additions and 5 deletions

View File

@@ -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

View File

@@ -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);
}