X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae5e1dcb68573e769b978b79ab08af64bd2ed177..730d336601a3ece761b56e7c05d1099352670a25:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index bf8cc72ded..8cc634935e 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -659,7 +659,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, if ( m_windowStyle & wxTR_FULL_ROW_HIGHLIGHT ) { - if ( wxTheApp->GetComCtl32Version() >= 471 ) + if ( wxApp::GetComCtl32Version() >= 471 ) wstyle |= TVS_FULLROWSELECT; } @@ -926,7 +926,7 @@ bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), wxT(""), wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), wxEmptyString, wxT("invalid tree item") ); wxChar buf[512]; // the size is arbitrary... @@ -2239,21 +2239,20 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara { bool processed = false; WXLRESULT rc = 0; - bool isMultiple = (GetWindowStyle() & wxTR_MULTIPLE) != 0; + bool isMultiple = HasFlag(wxTR_MULTIPLE); -#if (!defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 400)) - if (nMsg == WM_CONTEXTMENU) +#ifdef WM_CONTEXTMENU + if ( nMsg == WM_CONTEXTMENU ) { wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() ); event.m_item = GetSelection(); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); - - return rc; + if ( GetEventHandler()->ProcessEvent(event) ) + processed = true; + //else: continue with generating wxEVT_CONTEXT_MENU in base class code } -#endif // __SMARTPHONE__ - - if ( (nMsg >= WM_MOUSEFIRST) && (nMsg <= WM_MOUSELAST) ) +#endif // WM_CONTEXTMENU + else if ( (nMsg >= WM_MOUSEFIRST) && (nMsg <= WM_MOUSELAST) ) { // we only process mouse messages here and these parameters have the // same meaning for all of them @@ -2276,6 +2275,13 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara // newly selected item ::SelectItem(GetHwnd(), htItem); ::SetFocus(GetHwnd(), htItem); + + // default WM_RBUTTONUP handler enters modal loop inside + // DefWindowProc() waiting for WM_RBUTTONDOWN and then sends + // the resulting WM_CONTEXTMENU to the parent window, not us, + // which completely breaks everything so simply don't let it + // see this message at all + processed = true; break; #if !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE @@ -2426,9 +2432,9 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara // TreeView_GetItemRect() will return false if item is not visible, // which may happen perfectly well if ( TreeView_GetItemRect(GetHwnd(), HITEM_PTR(selections[n]), - &rect, true) ) + &rect, TRUE) ) { - ::InvalidateRect(GetHwnd(), &rect, false); + ::InvalidateRect(GetHwnd(), &rect, FALSE); } } } @@ -2571,6 +2577,10 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) eventType = wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT; TV_DISPINFO *info = (TV_DISPINFO *)lParam; + // although the user event handler may still veto it, it is + // important to set it now so that calls to SetItemText() from + // the event handler would change the text controls contents + m_idEdited = event.m_item = info->item.hItem; event.m_label = info->item.pszText; event.m_editCancelled = false; @@ -2903,7 +2913,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) wxASSERT_MSG( !m_dragImage, _T("starting to drag once again?") ); m_dragImage = new wxDragImage(*this, event.m_item); - m_dragImage->BeginDrag(wxPoint(0, 0), this); + m_dragImage->BeginDrag(wxPoint(0,0), this); m_dragImage->Show(); } break; @@ -2936,8 +2946,9 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case TVN_BEGINLABELEDIT: // return true to cancel label editing *result = !event.IsAllowed(); + // set ES_WANTRETURN ( like we do in BeginLabelEdit ) - if(event.IsAllowed()) + if ( event.IsAllowed() ) { HWND hText = TreeView_GetEditControl(GetHwnd()); if(hText != NULL) @@ -2962,6 +2973,10 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) | wxTE_PROCESS_ENTER); } } + else // we had set m_idEdited before + { + m_idEdited.Unset(); + } break; case TVN_ENDLABELEDIT: