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:
parent
3c1f8cb1f5
commit
a978c7d258
@ -1185,13 +1185,14 @@ void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
|
|||||||
{
|
{
|
||||||
wxPoint pt = event.GetPosition();
|
wxPoint pt = event.GetPosition();
|
||||||
wxTreeItemId item;
|
wxTreeItemId item;
|
||||||
if ( !HasFlag(wxTR_MULTIPLE) )
|
|
||||||
item = GetSelection();
|
|
||||||
wxLogMessage(wxT("OnContextMenu at screen coords (%i, %i)"), pt.x, pt.y);
|
wxLogMessage(wxT("OnContextMenu at screen coords (%i, %i)"), pt.x, pt.y);
|
||||||
|
|
||||||
// check if event was generated by keyboard (MSW-specific?)
|
// check if event was generated by keyboard (MSW-specific?)
|
||||||
if ( pt.x == -1 && pt.y == -1 ) //(this is how MSW indicates it)
|
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
|
// attempt to guess where to show the menu
|
||||||
if ( item.IsOk() )
|
if ( item.IsOk() )
|
||||||
{
|
{
|
||||||
@ -1208,6 +1209,7 @@ void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
|
|||||||
else // event was generated by mouse, use supplied coords
|
else // event was generated by mouse, use supplied coords
|
||||||
{
|
{
|
||||||
pt = ScreenToClient(pt);
|
pt = ScreenToClient(pt);
|
||||||
|
item = HitTest(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowMenu(item, pt);
|
ShowMenu(item, pt);
|
||||||
|
Loading…
Reference in New Issue
Block a user