]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 599043 ] fix for wxTreeCtrl/MSW right-click prob
authorJulian Smart <julian@anthemion.co.uk>
Sat, 31 Aug 2002 12:12:54 +0000 (12:12 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 31 Aug 2002 12:12:54 +0000 (12:12 +0000)
Benjamin I. Williams

There currently is a very significant problem with the
right-click behavior in wxTreeCtrl. The attached patch
file fixes this problem.

To better understand the problem, load up the tree
control, and start right-clicking on items. Note how
the focus rectangle does not behave properly. Next,
enable multiple selection. Now select several items,
and start right-clicking on the selected items. Note
how the selection highlights disappear.

If you try the tree sample with the generic tree
control, you will notice that the problem does not
occur, and that the tree control behaves properly.

This patch brings the MSW tree control implementation
in line with the generic implementation. This is the
same behavior that one can notice in applications such
as windows explorer and Visual Studio.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16888 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index d4a3025c38b675f582e05a8c62f544362a900a4e..cda27e031108c9993a3ad09f267c6ee49cdb1014 100644 (file)
@@ -1990,6 +1990,21 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 
         switch ( nMsg )
         {
+            case WM_RBUTTONDOWN:
+                // if the item we are about to right click on
+                // is not already select, remove the entire
+                // previous selection
+                if (!::IsItemSelected(GetHwnd(), htItem))
+                {
+                    UnselectAll();
+                }
+
+                // select item and set the focus to the
+                // newly selected item
+                ::SelectItem(GetHwnd(), htItem);
+                ::SetFocus(GetHwnd(), htItem);
+                break;
+
 #if !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
             case WM_LBUTTONDOWN:
                 if ( htItem && isMultiple )