leftKey rightKey bug on ListBox row Component


#1

Hi,

I've Component who react on leftKey and rightKey code in their keyPressed method.

I add them in juce::ListBox, everything work fine until horizontal Scrollbar appear.

In this case, Viewport::keyPressed interprets lefKey rightKey code instead of my Component.

To fix this issue, I had to modify the ListBox::ListViewport::keyPressed method like this:

    bool keyPressed (const KeyPress& key)
    {
        if (key.isKeyCode (KeyPress::upKey)
            || key.isKeyCode (KeyPress::downKey)
            || key.isKeyCode (KeyPress::pageUpKey)
            || key.isKeyCode (KeyPress::pageDownKey)
            || key.isKeyCode (KeyPress::homeKey)
            || key.isKeyCode (KeyPress::endKey)
            || key.isKeyCode (KeyPress::leftKey)  // this line was added
            || key.isKeyCode (KeyPress::rightKey) // this line was added
            )
        {
            const int allowableMods = owner.multipleSelection ? ModifierKeys::shiftModifier : 0;

            if ((key.getModifiers().getRawFlags() & ~allowableMods) == 0)
            {
                // we want to avoid these keypresses going to the viewport, and instead allow
                // them to pass up to our listbox..
                return false;
            }
        }

        return Viewport::keyPressed (key);
    }

I hope this can help

Thanks in advance for your concern about this issue.


#2

Thanks - yes, that sounds like it needs tweaking, will have a look!


#3

Your fix solves my issue.

Many thanks for this.