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 void
BColumnListView::KeyDown(const char* bytes, int32 numBytes) BColumnListView::KeyDown(const char* bytes, int32 numBytes)
{ {
char c = bytes[0]; char key = bytes[0];
switch (c) { switch (key) {
case B_RIGHT_ARROW: case B_RIGHT_ARROW:
case B_LEFT_ARROW: case B_LEFT_ARROW:
{ {
@@ -1699,9 +1699,9 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes)
float oldVal = fHorizontalScrollBar->Value(); float oldVal = fHorizontalScrollBar->Value();
float newVal = oldVal; float newVal = oldVal;
if (c == B_LEFT_ARROW) if (key == B_LEFT_ARROW)
newVal -= smallStep; newVal -= smallStep;
else if (c == B_RIGHT_ARROW) else if (key == B_RIGHT_ARROW)
newVal += smallStep; newVal += smallStep;
if (newVal < minVal) if (newVal < minVal)
@@ -1715,10 +1715,25 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes)
if (focusRow == NULL) if (focusRow == NULL)
break; break;
bool expanded = focusRow->IsExpanded(); bool isExpanded = focusRow->HasLatch()
if ((c == B_RIGHT_ARROW && !expanded) && focusRow->IsExpanded();
|| (c == B_LEFT_ARROW && expanded)) { switch (key) {
fOutlineView->ToggleFocusRowOpen(); 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; break;
@@ -1746,7 +1761,7 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes)
float currentValue = fVerticalScrollBar->Value(); float currentValue = fVerticalScrollBar->Value();
float newValue = currentValue; float newValue = currentValue;
if (c == B_PAGE_UP) if (key == B_PAGE_UP)
newValue -= largeStep; newValue -= largeStep;
else else
newValue += largeStep; newValue += largeStep;