Robin, that worked perfectly well for a single selection tree. However,
I am having some difficulty adapting it to work with multiple
selections. I find that I'm having to keep adding code to check for
event.ControlPressed(), event.ShiftPressed() etc.
I wonder if a patch to custom/treectrl so that when a tree has the
wx.TR_FULL_ROW_HIGHLIGHT style that the user can select anywhere on that
row. Unless there is some other way to do this without rewriting all the
selection code for my tree.
-Kyle Rickey
ยทยทยท
-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Monday, December 17, 2007 1:36 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] CustomTreeCtrl slow HitTest()
Rickey, Kyle W wrote:
I seem to be running into an issue where the HitTest is slow for a
TreeCtrl. I've got a customtreectrl with the style
wx.TR_FULL_ROW_HIGHLIGHT. I would like for the user to be able to
select
the row that an item is on and have it select that item. That was the
user doesn't have to click directly over the text.So I use HitTest() to figure out which item is where the user clicked.
The problem is that when the tree is changing selection, it seems to
be
kind of slow to update the frame.
The delay or slowness you are seeing is actually the time it takes to
press and release the mouse button, as the tree ctrl is not clearing the
old selected item until you release the mouse. So if you unselect it in
your handler then that apparent slowdown will not be there.
def OnTreeClick(self, event):
point = wx.Point(event.GetX(), event.GetY())
item = self.tree.HitTest(point)[0]
try:
if self.tree.IsSelected(item):
pass
else:
old = self.tree.GetSelection()
self.tree.SelectItem(item, True)
self.tree.SelectItem(old, False)
except:
pass
event.Skip()
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org