X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b143cf708ba5e419de4c3d0b03640eedb6b926d1..639848874998378be6823c5243641eb643a0b0bf:/samples/treectrl/treetest.cpp diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 1028d79f66..3af468f441 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -1185,13 +1185,14 @@ void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event) { wxPoint pt = event.GetPosition(); wxTreeItemId item; - if ( !HasFlag(wxTR_MULTIPLE) ) - item = GetSelection(); wxLogMessage(wxT("OnContextMenu at screen coords (%i, %i)"), pt.x, pt.y); // check if event was generated by keyboard (MSW-specific?) if ( pt.x == -1 && pt.y == -1 ) //(this is how MSW indicates it) { + if ( !HasFlag(wxTR_MULTIPLE) ) + item = GetSelection(); + // attempt to guess where to show the menu if ( item.IsOk() ) { @@ -1208,6 +1209,7 @@ void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event) else // event was generated by mouse, use supplied coords { pt = ScreenToClient(pt); + item = HitTest(pt); } ShowMenu(item, pt);