wxTreeCtrl with the style wxTR_MULTIPLE, missing events

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
In need of some credit
In need of some credit
Posts: 1
Joined: Tue May 13, 2008 11:53 am

wxTreeCtrl with the style wxTR_MULTIPLE, missing events

Post by bfi2 » Tue May 13, 2008 12:03 pm


I use wxTreeCtrl with the style wxTR_MULTIPLE. Under some circumstances I found a strange behaviour in my application. There are missing selection changed events under the conditions I’ll describe below:

Select Item 1, (multi)select Item(s) 2...n.

If I unselect the last selected Item no Event is received by my application that applies for all following left-clicks on this item. Same behaviour I can see running the sample application “treetest.cpp” coming with wxWidgets.

I'm currently using wxWidgets 2.8.7 Windows. Is there any solution for this issue in the meantime?


Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed May 23, 2007 3:41 pm
Location: London

Post by Qasim » Tue May 13, 2008 6:48 pm

I fixed that problem by using on mouse left button up event. There was nothing else which gets notified if you select and unselect the same item (using CTRL key). I did something like this

Code: Select all

tree->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(TreeView::OnMouseUp), NULL, this);

Code: Select all

void TreeView::OnMouseUp(wxMouseEvent& e)
wxArrayTreeItemIds	mSelectedItems;
//mSelected items will have corrent number of selected items now
Hope that helps
Who doubts nothing, Knows nothing

Post Reply