comctl32/treeview: Fix item dragging and selection for TVS_FULLROWSELECT style.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-08-10 15:11:02 +03:00 committed by Alexandre Julliard
parent 6531b9b8af
commit af02e10828
1 changed files with 34 additions and 13 deletions

View File

@ -4197,9 +4197,9 @@ TREEVIEW_LButtonDoubleClick(TREEVIEW_INFO *infoPtr, LPARAM lParam)
static LRESULT static LRESULT
TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam) TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
{ {
BOOL do_track, do_select, bDoLabelEdit;
HWND hwnd = infoPtr->hwnd; HWND hwnd = infoPtr->hwnd;
TVHITTESTINFO ht; TVHITTESTINFO ht;
BOOL bTrack, bDoLabelEdit;
/* If Edit control is active - kill it and return. /* If Edit control is active - kill it and return.
* The best way to do it is to set focus to itself. * The best way to do it is to set focus to itself.
@ -4219,15 +4219,32 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
TRACE("item %d\n", TREEVIEW_GetItemIndex(infoPtr, ht.hItem)); TRACE("item %d\n", TREEVIEW_GetItemIndex(infoPtr, ht.hItem));
/* update focusedItem and redraw both items */ /* update focusedItem and redraw both items */
if(ht.hItem && (ht.flags & TVHT_ONITEM)) if (ht.hItem)
{ {
infoPtr->focusedItem = ht.hItem; BOOL do_focus;
TREEVIEW_InvalidateItem(infoPtr, infoPtr->focusedItem);
TREEVIEW_InvalidateItem(infoPtr, infoPtr->selectedItem); if (TREEVIEW_IsFullRowSelect(infoPtr))
do_focus = ht.flags & (TVHT_ONITEMINDENT | TVHT_ONITEM | TVHT_ONITEMRIGHT);
else
do_focus = ht.flags & TVHT_ONITEM;
if (do_focus)
{
infoPtr->focusedItem = ht.hItem;
TREEVIEW_InvalidateItem(infoPtr, infoPtr->focusedItem);
TREEVIEW_InvalidateItem(infoPtr, infoPtr->selectedItem);
}
} }
bTrack = (ht.flags & TVHT_ONITEM) if (!(infoPtr->dwStyle & TVS_DISABLEDRAGDROP))
&& !(infoPtr->dwStyle & TVS_DISABLEDRAGDROP); {
if (TREEVIEW_IsFullRowSelect(infoPtr))
do_track = ht.flags & (TVHT_ONITEMINDENT | TVHT_ONITEM | TVHT_ONITEMRIGHT);
else
do_track = ht.flags & TVHT_ONITEM;
}
else
do_track = FALSE;
/* /*
* If the style allows editing and the node is already selected * If the style allows editing and the node is already selected
@ -4237,16 +4254,15 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
(ht.flags & TVHT_ONITEMLABEL) && (infoPtr->selectedItem == ht.hItem); (ht.flags & TVHT_ONITEMLABEL) && (infoPtr->selectedItem == ht.hItem);
/* Send NM_CLICK right away */ /* Send NM_CLICK right away */
if (!bTrack) if (!do_track && TREEVIEW_SendSimpleNotify(infoPtr, NM_CLICK))
if (TREEVIEW_SendSimpleNotify(infoPtr, NM_CLICK)) goto setfocus;
goto setfocus;
if (ht.flags & TVHT_ONITEMBUTTON) if (ht.flags & TVHT_ONITEMBUTTON)
{ {
TREEVIEW_Toggle(infoPtr, ht.hItem, TRUE); TREEVIEW_Toggle(infoPtr, ht.hItem, TRUE);
goto setfocus; goto setfocus;
} }
else if (bTrack) else if (do_track)
{ /* if TREEVIEW_TrackMouse == 1 dragging occurred and the cursor left the dragged item's rectangle */ { /* if TREEVIEW_TrackMouse == 1 dragging occurred and the cursor left the dragged item's rectangle */
if (TREEVIEW_TrackMouse(infoPtr, ht.pt)) if (TREEVIEW_TrackMouse(infoPtr, ht.pt))
{ {
@ -4268,9 +4284,14 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
} }
} }
if (bTrack && TREEVIEW_SendSimpleNotify(infoPtr, NM_CLICK)) if (do_track && TREEVIEW_SendSimpleNotify(infoPtr, NM_CLICK))
goto setfocus; goto setfocus;
if (TREEVIEW_IsFullRowSelect(infoPtr))
do_select = ht.flags & (TVHT_ONITEMINDENT | TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMRIGHT);
else
do_select = ht.flags & (TVHT_ONITEMICON | TVHT_ONITEMLABEL);
if (bDoLabelEdit) if (bDoLabelEdit)
{ {
if (infoPtr->Timer & TV_EDIT_TIMER_SET) if (infoPtr->Timer & TV_EDIT_TIMER_SET)
@ -4279,7 +4300,7 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
SetTimer(hwnd, TV_EDIT_TIMER, GetDoubleClickTime(), 0); SetTimer(hwnd, TV_EDIT_TIMER, GetDoubleClickTime(), 0);
infoPtr->Timer |= TV_EDIT_TIMER_SET; infoPtr->Timer |= TV_EDIT_TIMER_SET;
} }
else if (ht.flags & (TVHT_ONITEMICON|TVHT_ONITEMLABEL)) /* select the item if the hit was inside of the icon or text */ else if (do_select)
{ {
TREEVIEW_ITEM *selection = infoPtr->selectedItem; TREEVIEW_ITEM *selection = infoPtr->selectedItem;