]> git.saurik.com Git - wxWidgets.git/commitdiff
Show how to get the right position for HitTest from a mouse event position
authorRobin Dunn <robin@alldunn.com>
Mon, 6 Oct 2003 16:53:31 +0000 (16:53 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 6 Oct 2003 16:53:31 +0000 (16:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/wxTreeListCtrl.py

index e5b05a9106b9fb9564a1962961a73b89da7eecf4..2fb5fc370ed8fb80b2a795612c4b422098d59abd 100644 (file)
@@ -68,6 +68,20 @@ class TestPanel(wxPanel):
 
         self.tree.Expand(self.root)
 
+        EVT_RIGHT_UP(self.tree.GetMainWindow(), self.OnRightUp)
+
+
+    def OnRightUp(self, evt):
+        # Convert the position from being relative to the subwindow to
+        # being relative to the outer treelist window so HitTest will
+        # have the point it is expecting.
+        pos = evt.GetPosition()
+        pos = self.tree.GetMainWindow().ClientToScreen(pos)
+        pos = self.tree.ScreenToClient(pos)
+        item, flags, col = self.tree.HitTest(pos)
+        if item:
+            print flags, col, self.tree.GetItemText(item, col)
+
 
     def OnSize(self, evt):
         self.tree.SetSize(self.GetSize())