+ wxTreeItemId item = GetSelection();
+ wxLogMessage("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)
+ {
+ //attempt to guess where to show the menu
+ if (item.IsOk())
+ {
+ //if an item was clicked, show menu to the right of it
+ wxRect rect;
+ GetBoundingRect(item, rect, true); //true = only the label
+ pt = wxPoint(rect.GetRight(), rect.GetTop());
+ }
+ else
+ {
+ pt = wxPoint(0, 0);
+ }
+ }
+ else
+ {
+ //event was generated by mouse, use supplied coords
+ pt = ScreenToClient(pt);
+ }
+
+ ShowMenu(item, pt);