]> git.saurik.com Git - wxWidgets.git/commitdiff
set the focus to the tree before generating the selection change events to have a...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 1 Nov 2007 20:26:11 +0000 (20:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 1 Nov 2007 20:26:11 +0000 (20:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49588 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index fe5e91ee1de92b88dba02aebdf883e0fbf86bd21..2f3b650043fd1d741b3c7ee6fed04c61e36bcefb 100644 (file)
@@ -2593,6 +2593,19 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     event.m_itemOld = tv->itemOld.hItem;
                 }
             }
+
+            // we receive this message from WM_LBUTTONDOWN handler inside
+            // comctl32.dll and so before the click is passed to
+            // DefWindowProc() which sets the focus to the window which was
+            // clicked and this can lead to unexpected event sequences: for
+            // example, we may get a "selection change" event from the tree
+            // before getting a "kill focus" event for the text control which
+            // had the focus previously, thus breaking user code doing input
+            // validation
+            //
+            // to avoid such surprises, we force the generation of focus events
+            // now, before we generate the selection change ones
+            SetFocus();
             break;
 
             // instead of explicitly checking for _WIN32_IE, check if the