Changing the multiple selection behaviour in wxTreeCtrl

I want to mimic the multiple-selection-drag-and-drop behaviour that Windows
Explorer has with a wxTreeCtrl. In particular, if multiple items are
selected, then a left click on an already selected item does nothing. This
can be used to drag the multiple selections somewhere. If you let go of the
left button without moving, then the item that was clicked on is left
selected and the other items are all deselected.

I'm having much much trouble getting this behaviour with wxTreeCtrl as it
seems that any event I can find that gets called when I left click on an
already selected item happens *after* all the other items get deselected.

To see this behaviour - run the attached code and then do the following:

1) Select multiple items (either with shift+left click to get a range, or
ctrl+left click to get specific items)
2) Note the number of the last event (the code prints out events with index
numbers so you can tell what events have happened easily)
3) Left click on a selected item
4) Note that *all* of the events that happen see no selections (except the
last event when you release the mouse button which sees one selection).

I was in the middle of trying to keep track of what items had been selected
and reselecting them at appropriate times but it turned out to be really
hairy (especially since the logic behind what events occur when seems a
little twisted to me here).

Is there any event which occurs *before* the items are deselected and allows
me to delay their deselection in the situation I need?

Thanks in advance

S.

<<Tree.py>>

Tree.py (2.23 KB)

Sean Slattery wrote:

I want to mimic the multiple-selection-drag-and-drop behaviour that Windows
Explorer has with a wxTreeCtrl. In particular, if multiple items are
selected, then a left click on an already selected item does nothing. This
can be used to drag the multiple selections somewhere. If you let go of the
left button without moving, then the item that was clicked on is left
selected and the other items are all deselected.

I'm having much much trouble getting this behaviour with wxTreeCtrl as it
seems that any event I can find that gets called when I left click on an
already selected item happens *after* all the other items get deselected.

Please enter a bug report about this.

ยทยทยท

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