Calling ExpandDir() to notify the control that a new item was added in a
previously empty directory didn't work as wxTreeCtrl::SetItemHasChildren()
wasn't called.
Fix this by moving SetItemHasChildren() to ExpandDir() from OnExpandItem(), it
must be always done and not just in response to an interactive action.
Closes #12735.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66311
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// ctor when wxTR_HIDE_ROOT was specified
if (!m_rootId.IsOk())
// ctor when wxTR_HIDE_ROOT was specified
if (!m_rootId.IsOk())
m_rootId = m_treeCtrl->GetRootItem();
ExpandDir(parentId);
m_rootId = m_treeCtrl->GetRootItem();
ExpandDir(parentId);
- if ( m_treeCtrl->GetChildrenCount(parentId, false) == 0 )
- {
- m_treeCtrl->SetItemHasChildren(parentId, false);
- }
}
void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent &event )
}
void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent &event )
filenames.Sort(wxDirCtrlStringCompareFunction);
}
filenames.Sort(wxDirCtrlStringCompareFunction);
}
+ // Now we really know whether we have any children so tell the tree control
+ // about it.
+ m_treeCtrl->SetItemHasChildren(parentId, !dirs.empty() || !filenames.empty());
+
// Add the sorted dirs
size_t i;
for (i = 0; i < dirs.GetCount(); i++)
// Add the sorted dirs
size_t i;
for (i = 0; i < dirs.GetCount(); i++)
// assume that it does have children by default as it can take a long
// time to really check for this (think remote drives...)
//
// assume that it does have children by default as it can take a long
// time to really check for this (think remote drives...)
//
- // and if we're wrong, we'll correct it later in OnExpandItem() if
+ // and if we're wrong, we'll correct the icon later if
// the user really tries to open this item
m_treeCtrl->SetItemHasChildren(id);
}
// the user really tries to open this item
m_treeCtrl->SetItemHasChildren(id);
}