small cleanup in ListView:
* avoid setting fAnchorIndex multiple times in certain situations git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
17a815e0ad
commit
9fe394010b
@ -414,7 +414,7 @@ BListView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
bool extend
|
bool extend
|
||||||
= fListType == B_MULTIPLE_SELECTION_LIST
|
= fListType == B_MULTIPLE_SELECTION_LIST
|
||||||
&& (modifiers() & B_SHIFT_KEY) != 0;
|
&& (modifiers() & B_SHIFT_KEY) != 0;
|
||||||
|
|
||||||
switch (bytes[0]) {
|
switch (bytes[0]) {
|
||||||
case B_UP_ARROW:
|
case B_UP_ARROW:
|
||||||
{
|
{
|
||||||
@ -424,7 +424,7 @@ BListView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
} else {
|
} else {
|
||||||
if (fAnchorIndex > 0) {
|
if (fAnchorIndex > 0) {
|
||||||
if (!extend || fAnchorIndex <= fFirstSelected)
|
if (!extend || fAnchorIndex <= fFirstSelected)
|
||||||
Select(--fAnchorIndex, extend);
|
Select(fAnchorIndex - 1, extend);
|
||||||
else
|
else
|
||||||
Deselect(fAnchorIndex--);
|
Deselect(fAnchorIndex--);
|
||||||
}
|
}
|
||||||
@ -441,7 +441,7 @@ BListView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
} else {
|
} else {
|
||||||
if (fAnchorIndex < CountItems() - 1) {
|
if (fAnchorIndex < CountItems() - 1) {
|
||||||
if (!extend || fAnchorIndex >= fLastSelected)
|
if (!extend || fAnchorIndex >= fLastSelected)
|
||||||
Select(++fAnchorIndex, extend);
|
Select(fAnchorIndex + 1, extend);
|
||||||
else
|
else
|
||||||
Deselect(fAnchorIndex++);
|
Deselect(fAnchorIndex++);
|
||||||
}
|
}
|
||||||
@ -452,19 +452,19 @@ BListView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case B_HOME:
|
case B_HOME:
|
||||||
if (extend)
|
if (extend) {
|
||||||
Select(0, fAnchorIndex, true);
|
Select(0, fAnchorIndex, true);
|
||||||
else
|
fAnchorIndex = 0;
|
||||||
|
} else
|
||||||
Select(0, false);
|
Select(0, false);
|
||||||
fAnchorIndex = 0;
|
|
||||||
ScrollToSelection();
|
ScrollToSelection();
|
||||||
break;
|
break;
|
||||||
case B_END:
|
case B_END:
|
||||||
if (extend)
|
if (extend) {
|
||||||
Select(fAnchorIndex, CountItems() - 1, true);
|
Select(fAnchorIndex, CountItems() - 1, true);
|
||||||
else
|
fAnchorIndex = CountItems() - 1;
|
||||||
|
} else
|
||||||
Select(CountItems() - 1, false);
|
Select(CountItems() - 1, false);
|
||||||
fAnchorIndex = CountItems() - 1;
|
|
||||||
ScrollToSelection();
|
ScrollToSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1426,11 +1426,10 @@ BListView::_Select(int32 index, bool extend)
|
|||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
if (!extend) {
|
if (!extend && fFirstSelected != -1)
|
||||||
fAnchorIndex = index;
|
changed = _DeselectAll(index, index);
|
||||||
if (fFirstSelected != -1)
|
|
||||||
changed = _DeselectAll(index, index);
|
fAnchorIndex = index;
|
||||||
}
|
|
||||||
|
|
||||||
BListItem* item = ItemAt(index);
|
BListItem* item = ItemAt(index);
|
||||||
if (!item->IsEnabled() || item->IsSelected()) {
|
if (!item->IsEnabled() || item->IsSelected()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user