]> git.saurik.com Git - wxWidgets.git/commitdiff
Include the location of the item in the ITEM_MENU event generated by the menu key...
authorKevin Hock <hockkn@yahoo.com>
Sat, 21 May 2005 03:01:04 +0000 (03:01 +0000)
committerKevin Hock <hockkn@yahoo.com>
Sat, 21 May 2005 03:01:04 +0000 (03:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34204 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/treectlg.cpp

index c32ebbbe8fbe1a733d4cd0caf621fd00bff61429..5f9fd71482aaa6cf8bd44d19380808588c8a4c93 100644 (file)
@@ -2693,8 +2693,15 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
 
         case WXK_MENU:
             {
 
         case WXK_MENU:
             {
+                // Use the item's bounding rectangle to determine position for the event
+                wxRect ItemRect;
+                GetBoundingRect(m_current, ItemRect, true);
+
                 wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() );
                 event.m_item = m_current;
                 wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() );
                 event.m_item = m_current;
+                // Use the left edge, vertical middle
+                event.m_pointDrag = wxPoint(ItemRect.GetX(),
+                                            ItemRect.GetY() + ItemRect.GetHeight() / 2);
                 event.SetEventObject( this );
                 GetEventHandler()->ProcessEvent( event );
                 break;
                 event.SetEventObject( this );
                 GetEventHandler()->ProcessEvent( event );
                 break;
@@ -3226,6 +3233,14 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
             nevent.m_pointDrag = CalcScrolledPosition(pt);
             nevent.SetEventObject(this);
             event.Skip(!GetEventHandler()->ProcessEvent(nevent));
             nevent.m_pointDrag = CalcScrolledPosition(pt);
             nevent.SetEventObject(this);
             event.Skip(!GetEventHandler()->ProcessEvent(nevent));
+
+            // Consistent with MSW (for now), send the ITEM_MENU *after*
+            // the RIGHT_CLICK event. TODO: This behavior may change.
+            wxTreeEvent nevent2(wxEVT_COMMAND_TREE_ITEM_MENU, GetId());
+            nevent2.m_item = item;
+            nevent2.m_pointDrag = CalcScrolledPosition(pt);
+            nevent2.SetEventObject(this);
+            GetEventHandler()->ProcessEvent(nevent2);
         }
         else if ( event.LeftUp() )
         {
         }
         else if ( event.LeftUp() )
         {