The wxTreeCtrl has a bug in its arrow keys.
Uh, the wxTreeCtrl
Up select the next visible item
The wxTreeCtrl gets Left wrong. It does not opt to collapse.
The following sample works if you have inherited the tree control; otherwise refactor the 'self.' and adjust the binding. I added this to the ListAndTreeControls example.
def __init__(
... blah blah blah
EVT_KEY_DOWN(self, self.OnKey)
...
def OnKey(self, event):
'On <Left>, if the current item is expanded, collapse it'
key = event.KeyCode()
if key == WXK_LEFT:
ID = self.GetSelection()
if self.IsExpanded(ID):
self.Collapse(ID)
return
event.Skip()
It'd be nice if someone promoted this patch back up to the source (WxGtk) instead of only fixing it down here in the python.
--PhlIp
It seems to have been fixed now.. (well, the bindings are correct in the latest wxPython demo, and I can't see anything resembling your fix in the code)
WxTreeControlArrowKeyBug (last edited 2008-03-11 10:50:17 by localhost)