From: Vadim Zeitlin Date: Tue, 21 Aug 2001 15:17:48 +0000 (+0000) Subject: double click handling is finally correct in the treectrl X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ebb987b77baefa9e7e74fad6f434fa89ca28ff71 double click handling is finally correct in the treectrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11434 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 7f880bb4d9..cb51d15b54 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -2731,26 +2731,23 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) m_renameTimer->Stop(); m_lastOnSame = FALSE; - if (item->HasPlus() && !HasButtons()) + // send activate event first + wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() ); + nevent.m_item = (long) item; + nevent.m_code = 0; + CalcScrolledPosition(x, y, + &nevent.m_pointDrag.x, + &nevent.m_pointDrag.y); + nevent.SetEventObject( this ); + if ( !GetEventHandler()->ProcessEvent( nevent ) ) { - // If the control has no buttons,the only way - // to expand/collapse it is by double clicking - // an item. In this case we cannot send any - // activate event. - Toggle(item); - } - else - { - // If we have buttons, just send activate event. - wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, - GetId() ); - nevent.m_item = (long) item; - nevent.m_code = 0; - CalcScrolledPosition(x, y, - &nevent.m_pointDrag.x, - &nevent.m_pointDrag.y); - nevent.SetEventObject( this ); - GetEventHandler()->ProcessEvent( nevent ); + // if the user code didn't process the activate event, + // handle it ourselves by toggling the item when it is + // double clicked + if ( item->HasPlus() ) + { + Toggle(item); + } } } }