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.
This commit is contained in:
@@ -1656,24 +1656,36 @@ BColumnListView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
{
|
{
|
||||||
float minVal, maxVal;
|
if ((modifiers() & B_SHIFT_KEY) != 0) {
|
||||||
fHorizontalScrollBar->GetRange(&minVal, &maxVal);
|
float minVal, maxVal;
|
||||||
float smallStep, largeStep;
|
fHorizontalScrollBar->GetRange(&minVal, &maxVal);
|
||||||
fHorizontalScrollBar->GetSteps(&smallStep, &largeStep);
|
float smallStep, largeStep;
|
||||||
float oldVal = fHorizontalScrollBar->Value();
|
fHorizontalScrollBar->GetSteps(&smallStep, &largeStep);
|
||||||
float newVal = oldVal;
|
float oldVal = fHorizontalScrollBar->Value();
|
||||||
|
float newVal = oldVal;
|
||||||
|
|
||||||
if (c == B_LEFT_ARROW)
|
if (c == B_LEFT_ARROW)
|
||||||
newVal -= smallStep;
|
newVal -= smallStep;
|
||||||
else if (c == B_RIGHT_ARROW)
|
else if (c == B_RIGHT_ARROW)
|
||||||
newVal += smallStep;
|
newVal += smallStep;
|
||||||
|
|
||||||
if (newVal < minVal)
|
if (newVal < minVal)
|
||||||
newVal = minVal;
|
newVal = minVal;
|
||||||
else if (newVal > maxVal)
|
else if (newVal > maxVal)
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user