Positioning problem in Treelistctrl

Hi list,

The following snippet of code is used to display a menu on a
wxTreeListCtrl.

However, the menu is shown not on the position of the mouse pointer (as
it is supposed to do), but a almost a line above it. Also, the HitTest
gives me the wrong item back. As a matter of fact it gives the item
ABOVE the item that it is positioned at.

    def OnListRightDown(self, event):
        pt = event.GetPosition()
        self.y = event.GetY()
        self.x = event.GetX()
        self.item, flags, cols = self.StatusTree.HitTest(pt)
        self.soort, self.rec = self.StatusTree.GetPyData(self.item)
        if self.rec is None:
            wxBell()
            return
        event.Skip()
        
    def OnRightClick(self, event):
        if hasattr(self,"P_UpMenu"):
            self.PopupMenuXY(self.P_UpMenu.popupmnu, self.x, self.y)
        event.Skip()

The same code is working OK on a wxListCtrl. So is it a bug???

Kind regards,
Dick Kniep

Dick Kniep wrote:

Hi list,

The following snippet of code is used to display a menu on a
wxTreeListCtrl.

However, the menu is shown not on the position of the mouse pointer (as
it is supposed to do), but a almost a line above it. Also, the HitTest
gives me the wrong item back. As a matter of fact it gives the item
ABOVE the item that it is positioned at.

    def OnListRightDown(self, event):
        pt = event.GetPosition()
        self.y = event.GetY()
        self.x = event.GetX()
        self.item, flags, cols = self.StatusTree.HitTest(pt)
        self.soort, self.rec = self.StatusTree.GetPyData(self.item)
        if self.rec is None: wxBell()
            return
        event.Skip()
            def OnRightClick(self, event):
        if hasattr(self,"P_UpMenu"):
            self.PopupMenuXY(self.P_UpMenu.popupmnu, self.x, self.y)
        event.Skip()

The same code is working OK on a wxListCtrl. So is it a bug???

It's probably not taking into account the size of the header window, I seem to recall something like this being fixed a while back in wxListCtrl. Alberto, can you look into this?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!