From 8b27b730552bf7d9b4e339949a18f33645f34948 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 23 Nov 2014 09:57:18 -0500 Subject: [PATCH] BCLV: Adjust arrow key behavior. - Left/right arrow can now be used to collapse/expand the focus row. Holding shift reverts to the previous behavior of scrolling the view. --- src/kits/interface/ColumnListView.cpp | 42 +++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index 9c1ec4d72c..ce8237e4aa 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -1656,24 +1656,36 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes) case B_RIGHT_ARROW: case B_LEFT_ARROW: { - float minVal, maxVal; - fHorizontalScrollBar->GetRange(&minVal, &maxVal); - float smallStep, largeStep; - fHorizontalScrollBar->GetSteps(&smallStep, &largeStep); - float oldVal = fHorizontalScrollBar->Value(); - float newVal = oldVal; + if ((modifiers() & B_SHIFT_KEY) != 0) { + float minVal, maxVal; + fHorizontalScrollBar->GetRange(&minVal, &maxVal); + float smallStep, largeStep; + fHorizontalScrollBar->GetSteps(&smallStep, &largeStep); + float oldVal = fHorizontalScrollBar->Value(); + float newVal = oldVal; - if (c == B_LEFT_ARROW) - newVal -= smallStep; - else if (c == B_RIGHT_ARROW) - newVal += smallStep; + if (c == B_LEFT_ARROW) + newVal -= smallStep; + else if (c == B_RIGHT_ARROW) + newVal += smallStep; - if (newVal < minVal) - newVal = minVal; - else if (newVal > maxVal) - newVal = maxVal; + if (newVal < minVal) + newVal = minVal; + else if (newVal > maxVal) + newVal = maxVal; - fHorizontalScrollBar->SetValue(newVal); + fHorizontalScrollBar->SetValue(newVal); + } else { + BRow* focusRow = fOutlineView->FocusRow(); + if (focusRow == NULL) + break; + + bool expanded = focusRow->IsExpanded(); + if ((c == B_RIGHT_ARROW && !expanded) + || (c == B_LEFT_ARROW && expanded)) { + fOutlineView->ToggleFocusRowOpen(); + } + } break; }