show the item for which the context menu is shown correctly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42260 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-10-22 22:33:25 +00:00
parent 3c1f8cb1f5
commit a978c7d258

View File

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