Keyboard navigation fails when the first component is an editable Label or ComboBox

Hi all,

I’m using the keyboard to move between components. Tab moves to the next component and Shift+Tab moves to the previous component. I’m not doing anything special - just using JUCE’s built-in keyboard navigation capabilities.

If you press Shift + Tab on the first component, focus moves to the last component as expected. Similarly, if the last component is focused and you press Tab, focus moves to the first component.

This all works fine unless the first component happens to be an editable Label or ComboBox. Tab still moves to the next component, but Shift + Tab gets stuck on the Label/ComboBox text editor.

It’s easy to reproduce:

  1. Create a new Projucer GUI project.
    And in the MainComponent constructor…
  2. Add a Label and position it at the top. Call setEditable(true) on it.
  3. Add a TextButton (or whatever) and position it beneath the Label.
  4. Run the app and use Tab and Shift + Tab to navigate between the components.

If you don’t add the Label and instead add a second TextButton (for example), Shift + Tab works fine.

Assuming others can reproduce it, can it be fixed please?

Many thanks,
Ben

Going to cheekily nudge @ed95 since he’s responded to previous issues of a similar nature before. Thanks in advance!

Here’s my test project if it’s any use:
TestProject.zip (31.5 KB)

This has accessibility implications too.

If your dialog has an editable label or combobox at the top left, then you’re forced to hit Tab potentially hundreds of times to get to the dialog OK/Cancel buttons, rather than just pressing Shift + Tab to ‘wrap around’ to the confirmation buttons at the bottom.

We have a dialog with 3 tables in it, and our tables have several components per row. It’s no exaggeration that, depending on the circumstances, you sometimes have to hit Tab literally hundreds of times before you get to the OK/Cancel buttons.

FWIW, we currently have an accessibility consultant evaluating our software, and he highlighted it as a big issue.

I’ve had a look into this and think I’ve found the cause. Does the following patch fix the issue for you?

0001.patch (2.3 KB)

It does indeed! Works fine when I apply your patch. Thanks for jumping on it so quickly @ed95

This is on the develop branch now: