fix SelectItem() for single selection case which was broken by recent changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1671,15 +1671,26 @@ void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select)
|
|||||||
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item);
|
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item);
|
||||||
if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
|
if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
|
||||||
{
|
{
|
||||||
if ( !::SelectItem(GetHwnd(), HITEM(item), select) )
|
if ( HasFlag(wxTR_MULTIPLE) )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("TreeView_SelectItem"));
|
if ( !::SelectItem(GetHwnd(), HITEM(item), select) )
|
||||||
|
{
|
||||||
|
wxLogLastError(wxT("TreeView_SelectItem"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // ok
|
else // single selection
|
||||||
{
|
{
|
||||||
event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED);
|
// use TreeView_SelectItem() to deselect the previous selection
|
||||||
(void)GetEventHandler()->ProcessEvent(event);
|
if ( !TreeView_SelectItem(GetHwnd(), HITEM(item)) )
|
||||||
|
{
|
||||||
|
wxLogLastError(wxT("TreeView_SelectItem"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED);
|
||||||
|
(void)GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
//else: program vetoed the change
|
//else: program vetoed the change
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user