BOutlineListView: fix keyboard navigation

* On left arrow key select parent item when selected item is collapsed.
* Scroll to selected item when expanding/collapsing.

Change-Id: Ia404abb970376d4168efd8bba4d8817712a885a6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2873
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
X512 2020-06-03 17:52:17 +09:00 committed by waddlesplash
parent a9f415f06a
commit c47cb94a5e
1 changed files with 7 additions and 3 deletions

View File

@ -199,8 +199,10 @@ BOutlineListView::KeyDown(const char* bytes, int32 numBytes)
if (item && item->fHasSubitems) { if (item && item->fHasSubitems) {
if (!item->IsExpanded()) if (!item->IsExpanded())
Expand(item); Expand(item);
else else {
Select(currentSel + 1); Select(currentSel + 1);
ScrollToSelection();
}
} }
return; return;
} }
@ -209,12 +211,14 @@ BOutlineListView::KeyDown(const char* bytes, int32 numBytes)
{ {
BListItem* item = ItemAt(currentSel); BListItem* item = ItemAt(currentSel);
if (item) { if (item) {
if (item->fHasSubitems) if (item->fHasSubitems && item->IsExpanded())
Collapse(item); Collapse(item);
else { else {
item = Superitem(item); item = Superitem(item);
if (item) if (item) {
Select(IndexOf(item)); Select(IndexOf(item));
ScrollToSelection();
}
} }
} }
return; return;