Is there any kind of keyboard focus tutorial or overview article?

I am going absolutely crazy trying to get keyboard focus to work with my label and texteditor fields. I’ve been trying to get keyboard focus to work for several days…

I’ve Googled “JUCE keyboard focus” and searched for “keyboard focus” here and read most of the articles in this forum on the topic and I don’t find any of it helpful. It’s overspecific and assumes that I mostly understand it all already. I don’t.

I’m not even going to specify the specific problem I have, as I feel that I just have no clue about how any of this works anyway and I want to understand it properly, not just fix my current problem.

What I really need is a high-level tutorial article on keyboard focus. I want to understand how keyboard focus transfers between the DAW and the plugin and between the plugin top component and sub components and so on. I want to understand how to set the order of keyboard focus when the user hits Tab and how to make a component get keyboard focus when the user clicks on it. Do I need to set up handlers for mouse clicks and set the focus explicitly, or should methods such as setWantsKeyboardFocus(true) and setMouseClickGrabsKeyboardFocus do it automatically? I have no clue and nothing I try works. What I really want is a comprehensive overview to keyboard focus.

Does such an article exist?!

I haven’t personally seen a tutorial on that topic sadly. (Maybe there’s a video somewhere in the TheAudioProgrammer’s YouTube channel?)

What I do know is that the AccessibilityDemo creates a ComponentTraverser via the method createFocusTraverser which could perhaps help you get a handle on the situation.

Unfortunately I can’t give you any more specific help than that, but hopefully someone else can…

1 Like

This might not resolve all your high level needs, but I wrote about some of it here:

If you let me know what did / didn’t make sense to you after reading it, I can help fill in the gaps (also on the article for future readers).

5 Likes