+// Don't leave edit or selection on a child which is about to disappear
+void wxGenericTreeCtrl::ChildrenClosing(wxGenericTreeItem* item)
+{
+ if (m_textCtrl != NULL && item != m_textCtrl->item() && IsDescendantOf(item, m_textCtrl->item())) {
+ m_textCtrl->StopEditing();
+ }
+ if (item != m_key_current && IsDescendantOf(item, m_key_current)) {
+ m_key_current = NULL;
+ }
+ if (IsDescendantOf(item, m_select_me)) {
+ m_select_me = item;
+ }
+ if (item != m_current && IsDescendantOf(item, m_current)) {
+ m_current = NULL;
+ m_select_me = item;
+ }
+}
+