Tab key as command id trigger?


#1

Doesn’t seem to work.

Tab is listed as a keypress, not a modifier, but if I do:

addDefaultKeypress(KeyPress::spaceKey, 0);

the command triggers, whereas

addDefaultKeypress(KeyPress::tabKey, 0);

never fires.


#2

Perhaps it’s getting intercepted and used to move the keyboard focus between components…?


#3

hmm, yeah, that’s probably true.

I wasn’t really thinking about tab focus, cos it’s not applicable to my interface.

Nothing is ever simple. :slight_smile:


#4

How about this change, in ComponentPeer, 462:

        if (keyInfo.isKeyCode (KeyPress::tabKey) && Component::getCurrentlyFocusedComponent() != 0)
        {
            Component* const currentlyFocused = Component::getCurrentlyFocusedComponent();
            currentlyFocused->moveKeyboardFocusToSibling (! keyInfo.getModifiers().isShiftDown());
            keyWasUsed = (currentlyFocused != Component::getCurrentlyFocusedComponent());
            break;
        }

…it just adds a check to see if the focus actually changed, and if not, it shouldn’t consume the key event.


#5

I’ll give it a try.

Thanks Jules.