comctl32: Fix item selection with VK_SPACE when Ctrl is pressed (try2)
Nikolay Sivov
bunglehead at gmail.com
Tue Mar 10 18:17:04 CDT 2009
Keyboard listview item selection with Ctrl key pressed only should be done
with space key. Moving in a list with arrows should only move a focus,
space key should toggle selection of a currently focused item.
Changelog:
- try2: a comment on a new input argument added for LISTVIEW_KeySelection
- Fix item selection with VK_SPACE when Ctrl is pressed
>From 418aa4620b3c8a2e85ef6c28bd019118c548e0b5 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Tue, 10 Mar 2009 19:05:03 -0400
Subject: Fix item selection with VK_SPACE when Ctrl is pressed
---
dlls/comctl32/listview.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 66b45b4..5379561 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -425,7 +425,7 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *, INT, BOOL);
static LRESULT LISTVIEW_Command(const LISTVIEW_INFO *, WPARAM, LPARAM);
static BOOL LISTVIEW_SortItems(LISTVIEW_INFO *, PFNLVCOMPARE, LPARAM);
static INT LISTVIEW_GetStringWidthT(const LISTVIEW_INFO *, LPCWSTR, BOOL);
-static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *, INT);
+static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *, INT, BOOL);
static UINT LISTVIEW_GetItemState(const LISTVIEW_INFO *, INT, UINT);
static BOOL LISTVIEW_SetItemState(LISTVIEW_INFO *, INT, const LVITEMW *);
static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *, INT, INT, HWND);
@@ -1590,7 +1590,7 @@ static INT LISTVIEW_ProcessLetterKeys(LISTVIEW_INFO *infoPtr, WPARAM charCode, L
nItem = notify_hdr(infoPtr, LVN_ODFINDITEMW, (LPNMHDR)&nmlv.hdr);
if (nItem != -1)
- LISTVIEW_KeySelection(infoPtr, nItem);
+ LISTVIEW_KeySelection(infoPtr, nItem, FALSE);
return 0;
}
@@ -1623,7 +1623,7 @@ static INT LISTVIEW_ProcessLetterKeys(LISTVIEW_INFO *infoPtr, WPARAM charCode, L
} while (idx != endidx);
if (nItem != -1)
- LISTVIEW_KeySelection(infoPtr, nItem);
+ LISTVIEW_KeySelection(infoPtr, nItem, FALSE);
return 0;
}
@@ -3220,12 +3220,13 @@ static void LISTVIEW_SetSelection(LISTVIEW_INFO *infoPtr, INT nItem)
* PARAMETER(S):
* [I] infoPtr : valid pointer to the listview structure
* [I] nItem : item index
+ * [I] space : VK_SPACE code sent
*
* RETURN:
* SUCCESS : TRUE (needs to be repainted)
* FAILURE : FALSE (nothing has changed)
*/
-static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem)
+static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem, BOOL space)
{
/* FIXME: pass in the state */
WORD wShift = HIWORD(GetKeyState(VK_SHIFT));
@@ -3252,11 +3253,12 @@ static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem)
LVITEMW lvItem;
lvItem.state = ~LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED);
lvItem.stateMask = LVIS_SELECTED;
- LISTVIEW_SetItemState(infoPtr, nItem, &lvItem);
-
- if (lvItem.state & LVIS_SELECTED)
- infoPtr->nSelectionMark = nItem;
-
+ if (space)
+ {
+ LISTVIEW_SetItemState(infoPtr, nItem, &lvItem);
+ if (lvItem.state & LVIS_SELECTED)
+ infoPtr->nSelectionMark = nItem;
+ }
bResult = LISTVIEW_SetItemFocus(infoPtr, nItem);
}
else
@@ -8560,7 +8562,7 @@ static LRESULT LISTVIEW_KeyDown(LISTVIEW_INFO *infoPtr, INT nVirtualKey, LONG lK
}
if ((nItem != -1) && (nItem != infoPtr->nFocusedItem || nVirtualKey == VK_SPACE))
- LISTVIEW_KeySelection(infoPtr, nItem);
+ LISTVIEW_KeySelection(infoPtr, nItem, nVirtualKey == VK_SPACE);
return 0;
}
--
1.5.6.5
More information about the wine-patches
mailing list