comctl32/listview: Handle mouse selections more accurately.
This commit is contained in:
parent
8f5a1ae8c9
commit
d769368f66
|
@ -293,6 +293,7 @@ typedef struct tagLISTVIEW_INFO
|
||||||
HWND hwndEdit;
|
HWND hwndEdit;
|
||||||
WNDPROC EditWndProc;
|
WNDPROC EditWndProc;
|
||||||
INT nEditLabelItem;
|
INT nEditLabelItem;
|
||||||
|
INT nLButtonDownItem; /* tracks item to reset multiselection on WM_LBUTTONUP */
|
||||||
DWORD dwHoverTime;
|
DWORD dwHoverTime;
|
||||||
HWND hwndToolTip;
|
HWND hwndToolTip;
|
||||||
|
|
||||||
|
@ -3388,6 +3389,7 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN
|
||||||
{
|
{
|
||||||
POINT tmp;
|
POINT tmp;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
LVHITTESTINFO lvHitTestInfo;
|
||||||
WORD wDragWidth = GetSystemMetrics(SM_CXDRAG);
|
WORD wDragWidth = GetSystemMetrics(SM_CXDRAG);
|
||||||
WORD wDragHeight= GetSystemMetrics(SM_CYDRAG);
|
WORD wDragHeight= GetSystemMetrics(SM_CYDRAG);
|
||||||
|
|
||||||
|
@ -3399,11 +3401,33 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN
|
||||||
tmp.x = x;
|
tmp.x = x;
|
||||||
tmp.y = y;
|
tmp.y = y;
|
||||||
|
|
||||||
|
lvHitTestInfo.pt = tmp;
|
||||||
|
LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
|
||||||
|
|
||||||
|
/* reset item marker */
|
||||||
|
if (infoPtr->nLButtonDownItem != lvHitTestInfo.iItem)
|
||||||
|
infoPtr->nLButtonDownItem = -1;
|
||||||
|
|
||||||
if (!PtInRect(&rect, tmp))
|
if (!PtInRect(&rect, tmp))
|
||||||
{
|
{
|
||||||
LVHITTESTINFO lvHitTestInfo;
|
|
||||||
NMLISTVIEW nmlv;
|
NMLISTVIEW nmlv;
|
||||||
|
|
||||||
|
/* this path covers the following:
|
||||||
|
1. WM_LBUTTONDOWN over selected item (sets focus on it)
|
||||||
|
2. change focus with keys
|
||||||
|
3. move mouse over item from step 1 selects it and moves focus on it */
|
||||||
|
if (infoPtr->nLButtonDownItem != -1 &&
|
||||||
|
!LISTVIEW_GetItemState(infoPtr, infoPtr->nLButtonDownItem, LVIS_SELECTED))
|
||||||
|
{
|
||||||
|
LVITEMW lvItem;
|
||||||
|
|
||||||
|
lvItem.state = LVIS_FOCUSED | LVIS_SELECTED;
|
||||||
|
lvItem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
|
||||||
|
|
||||||
|
LISTVIEW_SetItemState(infoPtr, infoPtr->nLButtonDownItem, &lvItem);
|
||||||
|
infoPtr->nLButtonDownItem = -1;
|
||||||
|
}
|
||||||
|
|
||||||
lvHitTestInfo.pt = infoPtr->ptClickPos;
|
lvHitTestInfo.pt = infoPtr->ptClickPos;
|
||||||
LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
|
LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
|
||||||
|
|
||||||
|
@ -3420,8 +3444,6 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
infoPtr->bLButtonDown = FALSE;
|
|
||||||
|
|
||||||
/* see if we are supposed to be tracking mouse hovering */
|
/* see if we are supposed to be tracking mouse hovering */
|
||||||
if (LISTVIEW_isHotTracking(infoPtr)) {
|
if (LISTVIEW_isHotTracking(infoPtr)) {
|
||||||
|
@ -8144,6 +8166,7 @@ static LRESULT LISTVIEW_NCCreate(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING);
|
infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING);
|
||||||
infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING);
|
infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING);
|
||||||
infoPtr->nEditLabelItem = -1;
|
infoPtr->nEditLabelItem = -1;
|
||||||
|
infoPtr->nLButtonDownItem = -1;
|
||||||
infoPtr->dwHoverTime = -1; /* default system hover time */
|
infoPtr->dwHoverTime = -1; /* default system hover time */
|
||||||
infoPtr->nMeasureItemHeight = 0;
|
infoPtr->nMeasureItemHeight = 0;
|
||||||
infoPtr->xTrackLine = -1; /* no track line */
|
infoPtr->xTrackLine = -1; /* no track line */
|
||||||
|
@ -8835,10 +8858,15 @@ static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, IN
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED))
|
if (LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED))
|
||||||
|
{
|
||||||
infoPtr->nEditLabelItem = nItem;
|
infoPtr->nEditLabelItem = nItem;
|
||||||
|
infoPtr->nLButtonDownItem = nItem;
|
||||||
|
|
||||||
/* set selection (clears other pre-existing selections) */
|
LISTVIEW_SetItemFocus(infoPtr, nItem);
|
||||||
LISTVIEW_SetSelection(infoPtr, nItem);
|
}
|
||||||
|
else
|
||||||
|
/* set selection (clears other pre-existing selections) */
|
||||||
|
LISTVIEW_SetSelection(infoPtr, nItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8848,7 +8876,8 @@ static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, IN
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* remove all selections */
|
/* remove all selections */
|
||||||
LISTVIEW_DeselectAll(infoPtr);
|
if (!(wKey & MK_CONTROL) && !(wKey & MK_SHIFT))
|
||||||
|
LISTVIEW_DeselectAll(infoPtr);
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8885,6 +8914,11 @@ static LRESULT LISTVIEW_LButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT
|
||||||
/* set left button flag */
|
/* set left button flag */
|
||||||
infoPtr->bLButtonDown = FALSE;
|
infoPtr->bLButtonDown = FALSE;
|
||||||
|
|
||||||
|
/* set a single selection, reset others */
|
||||||
|
if(lvHitTestInfo.iItem == infoPtr->nLButtonDownItem && lvHitTestInfo.iItem != -1)
|
||||||
|
LISTVIEW_SetSelection(infoPtr, infoPtr->nLButtonDownItem);
|
||||||
|
infoPtr->nLButtonDownItem = -1;
|
||||||
|
|
||||||
if (infoPtr->bDragging)
|
if (infoPtr->bDragging)
|
||||||
{
|
{
|
||||||
infoPtr->bDragging = FALSE;
|
infoPtr->bDragging = FALSE;
|
||||||
|
|
Loading…
Reference in New Issue