ListBox::keyPressed and keyboard shortcuts


#1

ListBox::keyPressed does not take command modifiers into account. If there are keyboard shortcuts defined, e.g. Command-Down / Command-Up they will not be executed if a ListBox has focus. Would it make sense to change this method in such a way that it doesn’t handle key presses that contain only the command or control modifier?

[code]bool ListBox::keyPressed (const KeyPress& key)
{
const int numVisibleRows = viewport->getHeight() / getRowHeight();

const bool multiple = multipleSelection
                        && lastRowSelected >= 0
                        && key.getModifiers().isShiftDown();

if (key.isKeyCode (KeyPress::upKey))
{
    if (multiple)
        selectRangeOfRows (lastRowSelected, lastRowSelected - 1);
    else
        selectRow (jmax (0, lastRowSelected - 1));
}
else if (key.isKeyCode (KeyPress::downKey))
{
    if (multiple)
        selectRangeOfRows (lastRowSelected, lastRowSelected + 1);
    else
        selectRow (jmin (totalItems - 1, jmax (0, lastRowSelected) + 1));
}

}[/code]