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
This commit is contained in:
Oliver Tappe
2009-07-30 15:26:23 +00:00
parent 0fa107fd5d
commit 81bbdfe999
+9 -17
View File
@@ -374,7 +374,6 @@ BListView::MouseDown(BPoint point)
else else
Select(index); Select(index);
} }
fAnchorIndex = index;
} else { } else {
if (!(modifiers & B_COMMAND_KEY)) if (!(modifiers & B_COMMAND_KEY))
DeselectAll(); DeselectAll();
@@ -412,25 +411,22 @@ BListView::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
void void
BListView::KeyDown(const char *bytes, int32 numBytes) BListView::KeyDown(const char *bytes, int32 numBytes)
{ {
bool extend
= fListType == B_MULTIPLE_SELECTION_LIST
&& (modifiers() & B_SHIFT_KEY) != 0;
switch (bytes[0]) { switch (bytes[0]) {
case B_UP_ARROW: case B_UP_ARROW:
{ {
if (fFirstSelected == -1) { if (fFirstSelected == -1) {
// if nothing is selected yet, always select the first item // if nothing is selected yet, always select the first item
Select(0); Select(0);
fAnchorIndex = 0;
} else { } else {
bool extend = false;
if (fListType == B_MULTIPLE_SELECTION_LIST
&& (modifiers() & B_SHIFT_KEY) != 0)
extend = true;
if (fAnchorIndex > 0) { if (fAnchorIndex > 0) {
if (fAnchorIndex <= fFirstSelected) if (fAnchorIndex <= fFirstSelected)
Select(fAnchorIndex - 1, extend); Select(fAnchorIndex - 1, extend);
else else
Deselect(fAnchorIndex); Deselect(fAnchorIndex);
--fAnchorIndex;
} }
} }
@@ -442,19 +438,12 @@ BListView::KeyDown(const char *bytes, int32 numBytes)
if (fFirstSelected == -1) { if (fFirstSelected == -1) {
// if nothing is selected yet, always select the first item // if nothing is selected yet, always select the first item
Select(0); Select(0);
fAnchorIndex = 0;
} else { } else {
bool extend = false;
if (fListType == B_MULTIPLE_SELECTION_LIST
&& (modifiers() & B_SHIFT_KEY) != 0)
extend = true;
if (fAnchorIndex < CountItems() - 1) { if (fAnchorIndex < CountItems() - 1) {
if (fAnchorIndex >= fLastSelected) if (fAnchorIndex >= fLastSelected)
Select(fAnchorIndex + 1, extend); Select(fAnchorIndex + 1, extend);
else else
Deselect(fAnchorIndex); Deselect(fAnchorIndex);
++fAnchorIndex;
} }
} }
@@ -463,11 +452,11 @@ BListView::KeyDown(const char *bytes, int32 numBytes)
} }
case B_HOME: case B_HOME:
Select(0, fListType == B_MULTIPLE_SELECTION_LIST); Select(0, extend);
ScrollToSelection(); ScrollToSelection();
break; break;
case B_END: case B_END:
Select(CountItems() - 1, fListType == B_MULTIPLE_SELECTION_LIST); Select(CountItems() - 1, extend);
ScrollToSelection(); ScrollToSelection();
break; break;
@@ -1450,6 +1439,9 @@ BListView::_Select(int32 index, bool extend)
fLastSelected = index; fLastSelected = index;
} }
if (!extend)
fAnchorIndex = index;
ItemAt(index)->Select(); ItemAt(index)->Select();
if (Window()) if (Window())
InvalidateItem(index); InvalidateItem(index);