Hi,
I'd like to restrict a TR_MULTIPLE selection of a treectrl to the childs of one node only. For that purpose I'm using a TREE_SEL_CHANGING handler but I can't figure out how to distinguish wether the selection is growing, because the user is holding SHIFT or CONTROL or if its just a new single selection. Within the event handler, evt.GetItem() returns only the item which was hit by the mouse.
Regards, Christian
Christian Kristukat wrote:
Hi,
I'd like to restrict a TR_MULTIPLE selection of a treectrl to the childs of one node only. For that purpose I'm using a TREE_SEL_CHANGING handler but I can't figure out how to distinguish wether the selection is growing, because the user is holding SHIFT or CONTROL or if its just a new single selection. Within the event handler, evt.GetItem() returns only the item which was hit by the mouse.
I don't see anything in the code that would help, you'll probably have to do it the hard way. (Get all selected items and compare to all selected items from the last event.)
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Robin Dunn wrote:
Christian Kristukat wrote:
Hi,
I'd like to restrict a TR_MULTIPLE selection of a treectrl to the childs of one node only. For that purpose I'm using a TREE_SEL_CHANGING handler but I can't figure out how to distinguish wether the selection is growing, because the user is holding SHIFT or CONTROL or if its just a new single selection. Within the event handler, evt.GetItem() returns only the item which was hit by the mouse.I don't see anything in the code that would help, you'll probably have to do it the hard way. (Get all selected items and compare to all selected items from the last event.)
Ok, but the problem is that I must not veto the SEL_CHANGING event if want to know what the new selection is. So if don't vall veto(), the selection will be changed and the only thing I could do is to deselect by hand. Is that what you mean by 'the hard way'?
Regards, Christian
Christian Kristukat wrote:
Robin Dunn wrote:
Christian Kristukat wrote:
Hi,
I'd like to restrict a TR_MULTIPLE selection of a treectrl to the childs of one node only. For that purpose I'm using a TREE_SEL_CHANGING handler but I can't figure out how to distinguish wether the selection is growing, because the user is holding SHIFT or CONTROL or if its just a new single selection. Within the event handler, evt.GetItem() returns only the item which was hit by the mouse.I don't see anything in the code that would help, you'll probably have to do it the hard way. (Get all selected items and compare to all selected items from the last event.)
Ok, but the problem is that I must not veto the SEL_CHANGING event if want to know what the new selection is. So if don't vall veto(), the selection will be changed and the only thing I could do is to deselect by hand. Is that what you mean by 'the hard way'?
Sorry, I didn't read you original message closely enough. You can try using wx.GetKeyState(wx.WXK_SHIFT) or wx.GetKeyState(wx.WXK_CONTROL) to guess if the existing selection is being extended.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Robin Dunn wrote:
Christian Kristukat wrote:
Robin Dunn wrote:
Christian Kristukat wrote:
Hi,
I'd like to restrict a TR_MULTIPLE selection of a treectrl to the childs of one node only. For that purpose I'm using a TREE_SEL_CHANGING handler but I can't figure out how to distinguish wether the selection is growing, because the user is holding SHIFT or CONTROL or if its just a new single selection. Within the event handler, evt.GetItem() returns only the item which was hit by the mouse.I don't see anything in the code that would help, you'll probably have to do it the hard way. (Get all selected items and compare to all selected items from the last event.)
Ok, but the problem is that I must not veto the SEL_CHANGING event if want to know what the new selection is. So if don't vall veto(), the selection will be changed and the only thing I could do is to deselect by hand. Is that what you mean by 'the hard way'?
Sorry, I didn't read you original message closely enough. You can try using wx.GetKeyState(wx.WXK_SHIFT) or wx.GetKeyState(wx.WXK_CONTROL) to guess if the existing selection is being extended.
Thanks a lot. That works perfectly.
Christian