X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5fe302ef74b16d8fac0d9458d4658ea5143caaa6..e1673e527f08395de6864b09540162ca409a3c28:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 631b4ebce3..63019b5e22 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1948,7 +1948,9 @@ bool wxTreeCtrl::MSWShouldPreProcessMessage(WXMSG* msg) { if ( msg->message == WM_KEYDOWN ) { - if ( msg->wParam == VK_RETURN ) + // Only eat VK_RETURN if not being used by the application in + // conjunction with modifiers + if ( (msg->wParam == VK_RETURN) && !wxIsAnyModifierDown() ) { // we need VK_RETURN to generate wxEVT_COMMAND_TREE_ITEM_ACTIVATED return false; @@ -2147,6 +2149,38 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara } break; + case WM_RBUTTONDOWN: + // default handler removes the highlight from the currently + // focused item when right mouse button is pressed on another + // one but keeps the remaining items highlighted, which is + // confusing, so override this default behaviour for tree with + // multiple selections + if ( isMultiple ) + { + if ( !IsItemSelected(GetHwnd(), htItem) ) + { + UnselectAll(); + SelectItem(htItem); + ::SetFocus(GetHwnd(), htItem); + } + + // fire EVT_RIGHT_DOWN + HandleMouseEvent(nMsg, x, y, wParam); + + // send NM_RCLICK + NMHDR nmhdr; + nmhdr.hwndFrom = GetHwnd(); + nmhdr.idFrom = ::GetWindowLong(GetHwnd(), GWL_ID); + nmhdr.code = NM_RCLICK; + ::SendMessage(::GetParent(GetHwnd()), WM_NOTIFY, + nmhdr.idFrom, (LPARAM)&nmhdr); + + // prevent tree control default processing, as we've + // already done everything + processed = true; + } + break; + case WM_MOUSEMOVE: #ifndef __WXWINCE__ if ( m_htClickedItem ) @@ -2571,8 +2605,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // fabricate the lParam and wParam parameters sufficiently // similar to the ones from a "real" WM_KEYDOWN so that // CreateKeyEvent() works correctly - const bool isAltDown = ::GetKeyState(VK_MENU) < 0; - WXLPARAM lParam = (isAltDown ? KF_ALTDOWN : 0) << 16; + WXLPARAM lParam = (wxIsAltDown() ? KF_ALTDOWN : 0) << 16; WXWPARAM wParam = info->wVKey; @@ -2590,7 +2623,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) wParam); // a separate event for Space/Return - if ( !wxIsCtrlDown() && !wxIsShiftDown() && !isAltDown && + if ( !wxIsAnyModifierDown() && ((info->wVKey == VK_SPACE) || (info->wVKey == VK_RETURN)) ) { wxTreeItemId item; @@ -2608,7 +2641,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // Vista's tree control has introduced some problems with our // multi-selection tree. When TreeView_SelectItem() is called, // the wrong items are deselected. - + // Fortunately, Vista provides a new notification, TVN_ITEMCHANGING // that can be used to regulate this incorrect behavior. The // following messages will allow only the unlocked item's selection @@ -2625,7 +2658,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { // item's state is locked, don't allow the change // returning 1 will disallow the change - *result = 1; + *result = 1; return true; } }