From 7155254d3fc06bc772ba75e32c20441d0ddab5ad Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 29 Jul 2009 01:59:58 +0000 Subject: [PATCH] Fix several instances of the anchor index not being properly tracked. When shift-selecting via keyboard, rely on the anchor to know where to shift the selection towards. Fixes rest of ticket #4120. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31890 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ListView.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index a8d23049f3..057c13acf5 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -374,6 +374,7 @@ BListView::MouseDown(BPoint point) else Select(index); } + fAnchorIndex = index; } else { if (!(modifiers & B_COMMAND_KEY)) DeselectAll(); @@ -423,7 +424,13 @@ BListView::KeyDown(const char *bytes, int32 numBytes) && (modifiers() & B_SHIFT_KEY) != 0) extend = true; - Select(fFirstSelected - 1, extend); + if (fAnchorIndex > 0) { + if (fAnchorIndex <= fFirstSelected) + Select(fAnchorIndex - 1, extend); + else + Deselect(fAnchorIndex); + --fAnchorIndex; + } } ScrollToSelection(); @@ -439,8 +446,14 @@ BListView::KeyDown(const char *bytes, int32 numBytes) if (fListType == B_MULTIPLE_SELECTION_LIST && (modifiers() & B_SHIFT_KEY) != 0) extend = true; - - Select(fLastSelected + 1, extend); + + if (fAnchorIndex < CountItems() - 1) { + if (fAnchorIndex >= fLastSelected) + Select(fAnchorIndex + 1, extend); + else + Deselect(fAnchorIndex); + ++fAnchorIndex; + } } ScrollToSelection();