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

View File

@ -365,72 +365,66 @@ BListView::MouseMoved(BPoint pt, uint32 code, const BMessage *msg)
return;
}
// KeyDown
void
BListView::KeyDown(const char *bytes, int32 numBytes)
{
switch (bytes[0]) {
case B_UP_ARROW:
{
if (fFirstSelected == -1)
break;
bool extend = false;
if (fFirstSelected == -1) {
// if nothing is selected yet, always select the first item
Select(0);
} 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))
extend = true;
Select (fFirstSelected - 1, extend);
ScrollToSelection ();
Select(fFirstSelected - 1, extend);
}
ScrollToSelection();
break;
}
case B_DOWN_ARROW:
{
if (fFirstSelected == -1)
break;
bool extend = false;
if (fFirstSelected == -1) {
// if nothing is selected yet, always select the first item
Select(0);
} 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))
extend = true;
Select (fLastSelected + 1, extend);
ScrollToSelection ();
Select(fLastSelected + 1, extend);
}
ScrollToSelection();
break;
}
case B_HOME:
{
Select ( 0, fListType == B_MULTIPLE_SELECTION_LIST );
ScrollToSelection ();
Select(0, fListType == B_MULTIPLE_SELECTION_LIST);
ScrollToSelection();
break;
}
case B_END:
{
Select ( CountItems () - 1, fListType == B_MULTIPLE_SELECTION_LIST );
ScrollToSelection ();
Select(CountItems() - 1, fListType == B_MULTIPLE_SELECTION_LIST);
ScrollToSelection();
break;
}
case B_RETURN:
case B_SPACE:
{
Invoke ();
Invoke();
break;
}
default:
BView::KeyDown ( bytes, numBytes );
BView::KeyDown(bytes, numBytes);
}
}
// MakeFocus
void
BListView::MakeFocus(bool focused)
{