X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8e3f1cfb7892a1144385bbbd94e9d4f02d887d5..3a3dde0d44c43bc70a1e9791381ada04b4953a5d:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 416f0c5c42..f3733657d9 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -618,7 +618,9 @@ void wxTreeCtrl::Init() { m_textCtrl = NULL; m_hasAnyAttr = false; +#if wxUSE_DRAGIMAGE m_dragImage = NULL; +#endif m_pVirtualRoot = NULL; // initialize the global array of events now as it can't be done statically @@ -1671,15 +1673,26 @@ void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select) wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item); if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() ) { - if ( !::SelectItem(GetHwnd(), HITEM(item), select) ) + if ( HasFlag(wxTR_MULTIPLE) ) { - wxLogLastError(wxT("TreeView_SelectItem")); + if ( !::SelectItem(GetHwnd(), HITEM(item), select) ) + { + wxLogLastError(wxT("TreeView_SelectItem")); + return; + } } - else // ok + else // single selection { - event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED); - (void)GetEventHandler()->ProcessEvent(event); + // use TreeView_SelectItem() to deselect the previous selection + if ( !TreeView_SelectItem(GetHwnd(), HITEM(item)) ) + { + wxLogLastError(wxT("TreeView_SelectItem")); + return; + } } + + event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED); + (void)GetEventHandler()->ProcessEvent(event); } //else: program vetoed the change } @@ -2125,6 +2138,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara } #endif // __WXWINCE__ +#if wxUSE_DRAGIMAGE if ( m_dragImage ) { m_dragImage->Move(wxPoint(x, y)); @@ -2137,6 +2151,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara m_dragImage->Show(); } } +#endif // wxUSE_DRAGIMAGE break; case WM_LBUTTONUP: @@ -2162,6 +2177,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara // fall through case WM_RBUTTONUP: +#if wxUSE_DRAGIMAGE if ( m_dragImage ) { m_dragImage->EndDrag(); @@ -2178,6 +2194,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara // are selected simultaneously which is quite weird TreeView_SelectDropTarget(GetHwnd(), 0); } +#endif // wxUSE_DRAGIMAGE break; } } @@ -2318,6 +2335,24 @@ wxTreeCtrl::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) if ( wParam == VK_SPACE || wParam == VK_RETURN ) return 0; } +#if wxUSE_DRAGIMAGE + else if ( nMsg == WM_KEYDOWN ) + { + if ( wParam == VK_ESCAPE ) + { + if ( m_dragImage ) + { + m_dragImage->EndDrag(); + delete m_dragImage; + m_dragImage = NULL; + + // if we don't do it, the tree seems to think that 2 items + // are selected simultaneously which is quite weird + TreeView_SelectDropTarget(GetHwnd(), 0); + } + } + } +#endif // wxUSE_DRAGIMAGE return wxControl::MSWDefWindowProc(nMsg, wParam, lParam); } @@ -2706,6 +2741,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case TVN_BEGINDRAG: case TVN_BEGINRDRAG: +#if wxUSE_DRAGIMAGE if ( event.IsAllowed() ) { // normally this is impossible because the m_dragImage is @@ -2716,6 +2752,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) m_dragImage->BeginDrag(wxPoint(0,0), this); m_dragImage->Show(); } +#endif // wxUSE_DRAGIMAGE break; case TVN_DELETEITEM: