From: Julian Smart <julian@anthemion.co.uk> Date: Sat, 31 Aug 2002 12:12:54 +0000 (+0000) Subject: Applied patch [ 599043 ] fix for wxTreeCtrl/MSW right-click prob X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/de6ac3397dbd6ac5011cc9740822cb9b0f545014 Applied patch [ 599043 ] fix for wxTreeCtrl/MSW right-click prob 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 --- diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index d4a3025c38..cda27e0311 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -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 )