BColumnListView: fix keyboard navigation

Make expanding/collapsing logic the same as in BOutlineListView.

Change-Id: Ia8669ec6ac1be15c09879aa759474b4841451c39
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2933
Reviewed-by: John Scipione <[email protected]>
This commit is contained in:
X512
2020-06-20 18:14:48 +00:00
committed by waddlesplash
parent f29b420144
commit e1bb846d71
+24 -9
View File
@@ -1686,8 +1686,8 @@ BColumnListView::MessageReceived(BMessage* message)
void
BColumnListView::KeyDown(const char* bytes, int32 numBytes)
{
char c = bytes[0];
switch (c) {
char key = bytes[0];
switch (key) {
case B_RIGHT_ARROW:
case B_LEFT_ARROW:
{
@@ -1699,9 +1699,9 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes)
float oldVal = fHorizontalScrollBar->Value();
float newVal = oldVal;
if (c == B_LEFT_ARROW)
if (key == B_LEFT_ARROW)
newVal -= smallStep;
else if (c == B_RIGHT_ARROW)
else if (key == B_RIGHT_ARROW)
newVal += smallStep;
if (newVal < minVal)
@@ -1715,10 +1715,25 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes)
if (focusRow == NULL)
break;
bool expanded = focusRow->IsExpanded();
if ((c == B_RIGHT_ARROW && !expanded)
|| (c == B_LEFT_ARROW && expanded)) {
fOutlineView->ToggleFocusRowOpen();
bool isExpanded = focusRow->HasLatch()
&& focusRow->IsExpanded();
switch (key) {
case B_LEFT_ARROW:
if (isExpanded)
fOutlineView->ToggleFocusRowOpen();
else if (focusRow->fParent != NULL) {
fOutlineView->DeselectAll();
fOutlineView->SetFocusRow(focusRow->fParent, true);
fOutlineView->ScrollTo(focusRow->fParent);
}
break;
case B_RIGHT_ARROW:
if (!isExpanded)
fOutlineView->ToggleFocusRowOpen();
else
fOutlineView->ChangeFocusRow(false, true, false);
break;
}
}
break;
@@ -1746,7 +1761,7 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes)
float currentValue = fVerticalScrollBar->Value();
float newValue = currentValue;
if (c == B_PAGE_UP)
if (key == B_PAGE_UP)
newValue -= largeStep;
else
newValue += largeStep;