From 1da2783c334e028f775bcfb7b5f7e69ca66aff68 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Oct 2010 22:41:03 +0000 Subject: [PATCH] Don't grab focus when calling wxTreeCtrl::SelectItem(). The workaround for the unexpected events order introduced in r49588 should only apply to the situation when the user selects an item in the tree, not when it's done programmatically as this results in unexpected focus changes (see #11274). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65905 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/treectrl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 971470d442..9f1f4a7142 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1976,13 +1976,15 @@ void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select) if ( IsTreeEventAllowed(changingEvent) ) { + TempSetter set(m_changingSelection); + if ( !TreeView_SelectItem(GetHwnd(), HITEM(itemNew)) ) { wxLogLastError(wxT("TreeView_SelectItem")); } else // ok { - SetFocusedItem(item); + ::SetFocus(GetHwnd(), HITEM(item)); wxTreeEvent changedEvent(wxEVT_COMMAND_TREE_SEL_CHANGED, this, itemNew); @@ -3512,7 +3514,8 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // // to avoid such surprises, we force the generation of focus events // now, before we generate the selection change ones - SetFocus(); + if ( !m_changingSelection ) + SetFocus(); break; // instead of explicitly checking for _WIN32_IE, check if the -- 2.45.2