Simple way to set a custom component's accessibility so that it can be navigated to with TAB key?

Short Question:

Is there a simple way to set a custom component’s accessibility so that it can be navigated to with TAB key when accessibility / voiceover is switched on (only testing on Mac OS so far)

More Info:

I have a custom component with a couple of labels and custom paint function. It also behaves like a button through a custom mouse event function, however it does not inherit from the JUCE button class.

When adding accessibility to this app, I’ve noticed that any classes inheriting from the JUCE button class are by default able to be traversed with the tab key when voiceOver and accessibility are switched on (this is on Mac OS).

I’ve looked into AccessibilityHandler, FocusContainer etc, but not had any luck in getting the TAB key to navigate to my custom class. Also had a quick look how it’s implemented in the JUCE Button class, but that’s all tied to actually having a button to reference too.

Short of actually inheriting from JUCE button, how would I go about getting that same accessibility functionality in regards to the TAB key navigation?

If the class is based on a Component, then you just call setWantsKeyboardFocus(true).


Thank you!

I had actually tried setting that and it didn’t work, but just found that there is also a label component overlaid on top of my custom component. Setting setWantsKeyboardFocus(true) on the label did the trick :slight_smile:

1 Like