Fix selection events generation in multi-select wxTreeCtrl.
Only deselect the items when the mouse is released if really necessary: add a flag indicating when it is instead of trying to deduce it in the mouse up handler. Closes #11099 (thanks to Jonathan Liu). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61784 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -318,6 +318,9 @@ private:
|
|||||||
// whether we need to trigger a state image click event
|
// whether we need to trigger a state image click event
|
||||||
bool m_triggerStateImageClick;
|
bool m_triggerStateImageClick;
|
||||||
|
|
||||||
|
// whether we need to deselect other items on mouse up
|
||||||
|
bool m_mouseUpDeselect;
|
||||||
|
|
||||||
friend class wxTreeItemIndirectData;
|
friend class wxTreeItemIndirectData;
|
||||||
friend class wxTreeSortHelper;
|
friend class wxTreeSortHelper;
|
||||||
|
|
||||||
|
@@ -750,6 +750,7 @@ void wxTreeCtrl::Init()
|
|||||||
m_focusLost = true;
|
m_focusLost = true;
|
||||||
m_changingSelection = false;
|
m_changingSelection = false;
|
||||||
m_triggerStateImageClick = false;
|
m_triggerStateImageClick = false;
|
||||||
|
m_mouseUpDeselect = false;
|
||||||
|
|
||||||
// initialize the global array of events now as it can't be done statically
|
// 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
|
// with the wxEVT_XXX values being allocated during run-time only
|
||||||
@@ -2876,6 +2877,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetFocusedItem(wxTreeItemId(htItem));
|
SetFocusedItem(wxTreeItemId(htItem));
|
||||||
|
m_mouseUpDeselect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // click on a single selected item
|
else // click on a single selected item
|
||||||
@@ -3025,16 +3027,13 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
if ( isMultiple )
|
if ( isMultiple )
|
||||||
{
|
{
|
||||||
// deselect other items if multiple items selected
|
// deselect other items if needed
|
||||||
if ( htItem )
|
if ( htItem )
|
||||||
{
|
{
|
||||||
wxArrayTreeItemIds selections;
|
if ( m_mouseUpDeselect )
|
||||||
size_t count = GetSelections(selections);
|
|
||||||
|
|
||||||
if ( count > 1 &&
|
|
||||||
!(wParam & MK_CONTROL) &&
|
|
||||||
!(wParam & MK_SHIFT) )
|
|
||||||
{
|
{
|
||||||
|
m_mouseUpDeselect = false;
|
||||||
|
|
||||||
wxTreeEvent changingEvent(wxEVT_COMMAND_TREE_SEL_CHANGING,
|
wxTreeEvent changingEvent(wxEVT_COMMAND_TREE_SEL_CHANGING,
|
||||||
this, htItem);
|
this, htItem);
|
||||||
changingEvent.m_itemOld = htOldItem;
|
changingEvent.m_itemOld = htOldItem;
|
||||||
|
Reference in New Issue
Block a user