How do I set up these components for keyboard focus?


#1

I have the following components in my document window:

I would like to know how I set up the focus, focus traverser, and event handling to achieve the following:

  • When the user clicks anywhere inside of a deck (including child components), the deck becomes the ‘current’ deck and hilites appropriately.

  • When the number keys 1, 2, 3, or 4 are pressed, the corresponding buttons on the ‘current’ deck receive the keystroke. Note that each deck has the same set of buttons with the same keyboard shortcuts

  • Non-number keys are dispatched normally. So if there was an edit control outside of the decks it should be able to get keyboard focus as normal (un-hiliting the current deck)

Do I need to do this completely custom by handling key strokes or can I somehow get this working with button keyboard shortcuts?


#2

Take a look at the ApplicationCommandManager framework.


#3

Of course if I take over keyboard input at the highest level I am sure that I can get it to work but is there another way? One that doesn’t require centralization of all the shortcuts?

juce_Button already has a framework in place for assigning shortcuts, so I am wondering if it is possible using focus traverser, focus container, and the appropriate calls, to get the keyboard shortcuts working without having a central dispatch.


#4

Yes, you might be able to get it to do that just using button shortcuts and giving them the right focus orders.