From 81bbdfe9990b5051353f352691d53f23588067b9 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 30 Jul 2009 15:26:23 +0000 Subject: [PATCH] Fixed two problems in BListView: * fixed recent regression with respect to navigating via cursor keys * unified (and thus partly corrected) computation of whether or not we're in extend mode in KeyDown(), fixing the handling of unmodified B_HOME and B_END in multiselection mode git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31975 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ListView.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index d89b27a3b5..29fc09307d 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -374,7 +374,6 @@ BListView::MouseDown(BPoint point) else Select(index); } - fAnchorIndex = index; } else { if (!(modifiers & B_COMMAND_KEY)) DeselectAll(); @@ -412,25 +411,22 @@ BListView::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) void BListView::KeyDown(const char *bytes, int32 numBytes) { + bool extend + = fListType == B_MULTIPLE_SELECTION_LIST + && (modifiers() & B_SHIFT_KEY) != 0; + switch (bytes[0]) { case B_UP_ARROW: { if (fFirstSelected == -1) { // if nothing is selected yet, always select the first item Select(0); - fAnchorIndex = 0; } else { - bool extend = false; - if (fListType == B_MULTIPLE_SELECTION_LIST - && (modifiers() & B_SHIFT_KEY) != 0) - extend = true; - if (fAnchorIndex > 0) { if (fAnchorIndex <= fFirstSelected) Select(fAnchorIndex - 1, extend); else Deselect(fAnchorIndex); - --fAnchorIndex; } } @@ -442,19 +438,12 @@ BListView::KeyDown(const char *bytes, int32 numBytes) if (fFirstSelected == -1) { // if nothing is selected yet, always select the first item Select(0); - fAnchorIndex = 0; } else { - bool extend = false; - if (fListType == B_MULTIPLE_SELECTION_LIST - && (modifiers() & B_SHIFT_KEY) != 0) - extend = true; - if (fAnchorIndex < CountItems() - 1) { if (fAnchorIndex >= fLastSelected) Select(fAnchorIndex + 1, extend); else Deselect(fAnchorIndex); - ++fAnchorIndex; } } @@ -463,11 +452,11 @@ BListView::KeyDown(const char *bytes, int32 numBytes) } case B_HOME: - Select(0, fListType == B_MULTIPLE_SELECTION_LIST); + Select(0, extend); ScrollToSelection(); break; case B_END: - Select(CountItems() - 1, fListType == B_MULTIPLE_SELECTION_LIST); + Select(CountItems() - 1, extend); ScrollToSelection(); break; @@ -1450,6 +1439,9 @@ BListView::_Select(int32 index, bool extend) fLastSelected = index; } + if (!extend) + fAnchorIndex = index; + ItemAt(index)->Select(); if (Window()) InvalidateItem(index);