Fix unwanted focus events when deleting a wxTreeCtrl item in wxMSW.
Disable setting focus in response to TVN_SELCHANGING when deleting an item in a single selection control too -- this was already done in multi selection case but not in this one, for some reason. Also refactor the code to avoid duplicating TreeView_DeleteItem() calls. Closes #15721. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -304,6 +304,9 @@ private:
|
|||||||
// item visually spans the entire breadth of the window then
|
// item visually spans the entire breadth of the window then
|
||||||
bool MSWIsOnItem(unsigned flags) const;
|
bool MSWIsOnItem(unsigned flags) const;
|
||||||
|
|
||||||
|
// Delete the given item from the native control.
|
||||||
|
bool MSWDeleteItem(const wxTreeItemId& item);
|
||||||
|
|
||||||
|
|
||||||
// the hash storing the items attributes (indexed by item ids)
|
// the hash storing the items attributes (indexed by item ids)
|
||||||
wxMapTreeAttr m_attrs;
|
wxMapTreeAttr m_attrs;
|
||||||
|
@@ -1598,6 +1598,18 @@ wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent,
|
|||||||
return DoInsertAfter(parent, idPrev, text, image, selectedImage, data);
|
return DoInsertAfter(parent, idPrev, text, image, selectedImage, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxTreeCtrl::MSWDeleteItem(const wxTreeItemId& item)
|
||||||
|
{
|
||||||
|
TempSetter set(m_changingSelection);
|
||||||
|
if ( !TreeView_DeleteItem(GetHwnd(), HITEM(item)) )
|
||||||
|
{
|
||||||
|
wxLogLastError(wxT("TreeView_DeleteItem"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void wxTreeCtrl::Delete(const wxTreeItemId& item)
|
void wxTreeCtrl::Delete(const wxTreeItemId& item)
|
||||||
{
|
{
|
||||||
// unlock tree selections on vista, without this the
|
// unlock tree selections on vista, without this the
|
||||||
@@ -1619,14 +1631,8 @@ void wxTreeCtrl::Delete(const wxTreeItemId& item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if ( !MSWDeleteItem(item) )
|
||||||
TempSetter set(m_changingSelection);
|
|
||||||
if ( !TreeView_DeleteItem(GetHwnd(), HITEM(item)) )
|
|
||||||
{
|
|
||||||
wxLogLastError(wxT("TreeView_DeleteItem"));
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !selected )
|
if ( !selected )
|
||||||
{
|
{
|
||||||
@@ -1657,10 +1663,7 @@ void wxTreeCtrl::Delete(const wxTreeItemId& item)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !TreeView_DeleteItem(GetHwnd(), HITEM(item)) )
|
MSWDeleteItem(item);
|
||||||
{
|
|
||||||
wxLogLastError(wxT("TreeView_DeleteItem"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user