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
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);