X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..e75390d4aa51b46b9217dc4699267c1345893054:/src/msw/treectrl.cpp?ds=inline diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 776740fa1c..b408ac740d 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -750,6 +750,7 @@ void wxTreeCtrl::Init() m_focusLost = true; m_changingSelection = false; m_triggerStateImageClick = false; + m_mouseUpDeselect = false; // initialize the global array of events now as it can't be done statically // with the wxEVT_XXX values being allocated during run-time only @@ -2717,9 +2718,17 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) if ( !(tvht.flags & TVHT_ONITEM) ) { - if ( !HandleMouseEvent(nMsg, x, y, wParam) ) + if ( tvht.flags & TVHT_ONITEMBUTTON ) { - if ( tvht.flags & TVHT_ONITEMBUTTON ) + // either it's going to be handled by user code or + // we're going to use it ourselves to toggle the + // branch, in either case don't pass it to the base + // class which would generate another mouse click event + // for it even though it's already handled here + processed = true; + SetFocus(); + + if ( !HandleMouseEvent(nMsg, x, y, wParam) ) { if ( !IsExpanded(htItem) ) { @@ -2730,8 +2739,6 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) Collapse(htItem); } } - - processed = true; } m_focusLost = false; @@ -2870,6 +2877,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) else { SetFocusedItem(wxTreeItemId(htItem)); + m_mouseUpDeselect = true; } } else // click on a single selected item @@ -3019,16 +3027,13 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) case WM_LBUTTONUP: if ( isMultiple ) { - // deselect other items if multiple items selected + // deselect other items if needed if ( htItem ) { - wxArrayTreeItemIds selections; - size_t count = GetSelections(selections); - - if ( count > 1 && - !(wParam & MK_CONTROL) && - !(wParam & MK_SHIFT) ) + if ( m_mouseUpDeselect ) { + m_mouseUpDeselect = false; + wxTreeEvent changingEvent(wxEVT_COMMAND_TREE_SEL_CHANGING, this, htItem); changingEvent.m_itemOld = htOldItem;