12-11-2005 07:18 AM - edited 12-11-2005 07:18 AM
Message Edited by rag3ous on 12-11-2005 07:21 AM
12-12-2005 11:28 AM
12-12-2005 01:11 PM
Using the EVENT_VAL_CHANGED event to keep track of selection changes can give you incorrect results since.....
1) as you noted, the selection isn't updated until after the tree receives the EVENT_VAL_CHANGED. Even if you posted a deferred callback that is called after the tree is updated, you can still get an incorrect selection since....
2) the selection can change without the active item changing. For example, hit <ctrl+spacebar> on a tree in multiple selection mode, and the active item's selection is toggled and you don't get an EVENT_VAL_CHANGED since the active item was never changed.
Check out the help page on 'TreeControl Events', and look at the EVENT_SELECTION_CHANGE. This event is sent for each item when it's selection state is about to change. This event is swallowable for trees, so the selection state is not updated until after the event is sent and the event was not swallowed. Use eventData2 and eventData1, which indicate the item index whose selection state is about to change and it's new selection state.
Note that the EVENT_SELECTION_CHANGE is sent for each item, so if you group select or deselect items, you'll get multiple events.
- jared
12-13-2005 04:19 AM
Mert and Jared, thanks for your reply.
I realized I have to use such function in order to be able to see the changes immediately, I just didn't know which one.
PostDeferredCall does the job.
I've also checked and noticed the difference between EVENT_SELECTION_CHANGE and EVENT_VAL_CHANGED, indeed I have to use EVENT_SELECTION_CHANGE.
Thanks alot for the help.
Alex.