Arrow-up/down will now select the first item in the list if there is no selected

item yet.
This fixes bug #728.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18480 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-08-11 09:38:18 +00:00
parent 9515b3f27d
commit 943da1a9b7
+33 -39
View File
@@ -365,72 +365,66 @@ BListView::MouseMoved(BPoint pt, uint32 code, const BMessage *msg)
return; return;
} }
// KeyDown
void void
BListView::KeyDown(const char *bytes, int32 numBytes) BListView::KeyDown(const char *bytes, int32 numBytes)
{ {
switch (bytes[0]) { switch (bytes[0]) {
case B_UP_ARROW: case B_UP_ARROW:
{ {
if (fFirstSelected == -1) if (fFirstSelected == -1) {
break; // if nothing is selected yet, always select the first item
Select(0);
bool extend = false; } else {
bool extend = false;
if (fListType == B_MULTIPLE_SELECTION_LIST
&& (modifiers() & B_SHIFT_KEY) != 0)
extend = true;
if (fListType == B_MULTIPLE_SELECTION_LIST && (modifiers() & B_SHIFT_KEY)) Select(fFirstSelected - 1, extend);
extend = true; }
Select (fFirstSelected - 1, extend);
ScrollToSelection ();
ScrollToSelection();
break; break;
} }
case B_DOWN_ARROW: case B_DOWN_ARROW:
{ {
if (fFirstSelected == -1) if (fFirstSelected == -1) {
break; // if nothing is selected yet, always select the first item
Select(0);
bool extend = false; } else {
bool extend = false;
if (fListType == B_MULTIPLE_SELECTION_LIST
&& (modifiers() & B_SHIFT_KEY) != 0)
extend = true;
if (fListType == B_MULTIPLE_SELECTION_LIST && (modifiers() & B_SHIFT_KEY)) Select(fLastSelected + 1, extend);
extend = true; }
Select (fLastSelected + 1, extend);
ScrollToSelection ();
ScrollToSelection();
break; break;
} }
case B_HOME: case B_HOME:
{ Select(0, fListType == B_MULTIPLE_SELECTION_LIST);
Select ( 0, fListType == B_MULTIPLE_SELECTION_LIST ); ScrollToSelection();
ScrollToSelection ();
break; break;
}
case B_END: case B_END:
{ Select(CountItems() - 1, fListType == B_MULTIPLE_SELECTION_LIST);
Select ( CountItems () - 1, fListType == B_MULTIPLE_SELECTION_LIST ); ScrollToSelection();
ScrollToSelection ();
break; break;
}
case B_RETURN: case B_RETURN:
case B_SPACE: case B_SPACE:
{ Invoke();
Invoke ();
break; break;
}
default: default:
BView::KeyDown ( bytes, numBytes ); BView::KeyDown(bytes, numBytes);
} }
} }
// MakeFocus
void void
BListView::MakeFocus(bool focused) BListView::MakeFocus(bool focused)
{ {