I have a wxTreeCtrl defined with wxTR_SINGLE and wxTR_HIDE_ROOT. After an item is selected I try tree->Unselect() (within a right click event) but this fires a wxEVT_TREE_SEL_CHANGED event, automatically selecting the first item in the tree, which is not what I was looking for. If the first item is to be selected then this must be a user's choice.
In other words, how do I unselect a selected item?
The sample does not offer the option to unselect an item without selecting another item.
I tried using a 'clearSelection' variable to indicate that SelChange should not get involved, but the first item is still getting selected.
Code: Select all
void Interro::OnTREECTRLInterroCategoriesSelChanged( wxTreeEvent& WXUNUSED(event))
{
if (clearSelection)
{
clearSelection = false;
return;
}
selectedItem = tree_Categories->GetSelection();
}
void Interro::OnTREECTRLInterroCategoriesRightClick( wxTreeEvent& event)
{
clearSelection = true;
tree_Categories->Unselect();
}