EVT_TREE_SEL_CHANGED gets fired twice

Just for information. Maybe the cause is not in the Windows Tree control.

Below is a log of two SEL_CHANGED events that happen after programmatic
selection of added items.

'old' is the result of event.GetOldItem();
'cur' is the result of event.GetItem();
'sel' is the result of tree.GetSelection()

Interesting, that:
Second event's current item is the first events old item;
Second event's old item is invalid.

Add node
---- selection change event -----
old: <C wxTreeItemId instance at _e7e058_wxTreeItemId_p> old.IsOk(): 1
cur: <C wxTreeItemId instance at _d369e0_wxTreeItemId_p> cur.IsOk(): 1
sel: <C wxTreeItemId instance at _e5fc48_wxTreeItemId_p> sel.IsOk(): 1
old==cur: 0
cur==sel: 1
old==sel: 0
---- selection change event -----
old: <C wxTreeItemId instance at _e85f18_wxTreeItemId_p> old.IsOk(): 0
cur: <C wxTreeItemId instance at _e7e058_wxTreeItemId_p> cur.IsOk(): 1
sel: <C wxTreeItemId instance at _e5fc48_wxTreeItemId_p> sel.IsOk(): 1
old==cur: 0
cur==sel: 1
old==sel: 0

By the way, what about vetoing the events?

Peteris Martinsons

Peteris_Martinsons@exigengroup.lv wrote:

By the way, what about vetoing the events?

You should be able to veto the CHANGING event to prevent the selection from being changed and sending the CHANGED event. I'm not sure what effect vetoing the CHANGING event would have...

ยทยทยท

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