TableListBox steals up & down arrows


#1

It looks like TableListBox grabs the up and down arrow keys so they don’t show up in keyPressed() like the left & right arrows do.

Is there any way to get those key presses?


#2

If I put a breakpoint in my TableListBox in keyPressed() it breaks on a Down or Up arrow

Rail


#3

Did you subclass TableListBox?

I just added a TableListBox to my editor and made the editor a KeyListener. That’s where I get the left and right arrow presses and everything else, except up/down arrows and return.


#4

Mine is a sub class.

bool CGroupTable::keyPressed (const KeyPress& key)
{
    m_iFirstGroup = getFirstGroup();
    m_iLastGroup  = getLastGroup();

    if (key.isKeyCode (KeyPress::homeKey) && m_iFirstGroup != -1)
        {
        scrollToEnsureRowIsOnscreen (0);
        selectRow (m_iFirstGroup);

        return true;
        }

    if (key.isKeyCode (KeyPress::endKey) && m_iLastGroup != -1)
        {
        scrollToEnsureRowIsOnscreen (m_pGroupArray->size() - 1);

        selectRow (m_iLastGroup);

        return true;
        }

    if (key.isKeyCode (KeyPress::rightKey) && (m_pPartTable != nullptr))
        {
        m_pPartTable->grabKeyboardFocus();

        return true;
       }

    return ListBox::keyPressed (key);
}

I don’t change the Up/Down behavior so they’re sent to the base class.

Rail


#5

Thanks. Not sure why I didn’t think of subclassing it. Could be my Objective-C roots. :wink: