treelist select on rightclick not working

Hi All,

I want the item to be selected on right click. I tried calling
SelectItem manually. But it is not working
it not finding the item . what am i doing wrong?

def OnTreeListCtrl1TreeItemRightClick(self, event):
        pt=self.treeListCtrl1.ScreenToClient(wx.GetMousePosition())
        item, flags,column = self.treeListCtrl1.HitTest
(wx.GetMousePosition())
        if item:
           self.treeListCtrl1.SelectItem(item)
        else:
            print "no item found"
        self.treeListCtrl1.PopupMenu(self.menu1)
        event.Skip()

its printing no item found

binding# self.treeListCtrl1.Bind
(wx.EVT_TREE_ITEM_RIGHT_CLICK,self.OnTreeListCtrl1TreeItemRightClick,id=wxID_FRAME1TREELISTCTRL1)

styles used#
wx.TR_HAS_BUTTONS|wx.TR_ROW_LINES|wx.TR_NO_LINES|wx.TR_HIDE_ROOT|
wx.TR_FULL_ROW_HIGHLIGHT)

Simple, just use:

        self.treectrl.SelectItem(event.GetItem())

Let me know if you have any other problems :smiley:

michael

···

On Nov 25, 6:00 pm, thomas <tctho...@gmail.com> wrote:

Hi All,

I want the item to be selected on right click. I tried calling
SelectItem manually. But it is not working
it not finding the item . what am i doing wrong?

def OnTreeListCtrl1TreeItemRightClick(self, event):
pt=self.treeListCtrl1.ScreenToClient(wx.GetMousePosition())
item, flags,column = self.treeListCtrl1.HitTest
(wx.GetMousePosition())
if item:
self.treeListCtrl1.SelectItem(item)
else:
print "no item found"
self.treeListCtrl1.PopupMenu(self.menu1)
event.Skip()

its printing no item found

binding# self.treeListCtrl1.Bind
(wx.EVT_TREE_ITEM_RIGHT_CLICK,self.OnTreeListCtrl1TreeItemRightClick,id=wxID_FRAME1TREELISTCTRL1)

styles used#
wx.TR_HAS_BUTTONS|wx.TR_ROW_LINES|wx.TR_NO_LINES|wx.TR_HIDE_ROOT|
wx.TR_FULL_ROW_HIGHLIGHT)

Hi michael,

Thanks a lot that worked ..

Thanks
Thomas

···

On Nov 26, 1:04 pm, michael h <michaelke...@gmail.com> wrote:

Simple, just use:

    self\.treectrl\.SelectItem\(event\.GetItem\(\)\)

Let me know if you have any other problems :smiley:

michael

On Nov 25, 6:00 pm, thomas <tctho...@gmail.com> wrote:

> Hi All,

> I want the item to be selected on right click. I tried calling
> SelectItem manually. But it is not working
> it not finding the item . what am i doing wrong?

> def OnTreeListCtrl1TreeItemRightClick(self, event):
> pt=self.treeListCtrl1.ScreenToClient(wx.GetMousePosition())
> item, flags,column = self.treeListCtrl1.HitTest
> (wx.GetMousePosition())
> if item:
> self.treeListCtrl1.SelectItem(item)
> else:
> print "no item found"
> self.treeListCtrl1.PopupMenu(self.menu1)
> event.Skip()

> its printing no item found

> binding# self.treeListCtrl1.Bind
> (wx.EVT_TREE_ITEM_RIGHT_CLICK,self.OnTreeListCtrl1TreeItemRightClick,id=wxID_FRAME1TREELISTCTRL1)

> styles used#
> wx.TR_HAS_BUTTONS|wx.TR_ROW_LINES|wx.TR_NO_LINES|wx.TR_HIDE_ROOT|
> wx.TR_FULL_ROW_HIGHLIGHT)