Windows 10 Platform
C++20 development.
I am trying to get the row that a right-click context menu was clicked on. The row is not necessarily selected so using GetSelectedRow() is not an option.
My idea is to use HitTest() to get the item that was clicked and then use ItemToRow() to get the row.
My code below has an exception at the call to HitTest().
Code: Select all
wxDataViewItem item;
wxDataViewColumn* colPtr = nullptr;
wxDataViewListCtrl* dv = static_cast<wxDataViewListCtrl*>(e.GetEventObject());
wxPoint scrP = wxGetMousePosition();
wxPoint dvP = dv->ScreenToClient(wxGetMousePosition());
dv->HitTest(dvP, item, colPtr);
int row = dv->ItemToRow(item);
Another thing that is strange is that the two points scrP and dvP return the exact same coordinates which does not seem right at all.
It makes me feel that the dv pointer is not really a true wxDataViewListCtrl object, however I use the exact same code in other handlers to read the values from selected rows so it does seem to work.
Looking for some help or advice.