TableListBox with Accessibility


part of my UI is a TableListBox and I’m trying to make it screen reader aware. Here’s the UI.

Right now the screen reader “works” in that you can select the table and arrow across the rows and get things like “table, row 3 column 0” spoken. But I obviously want to replace that.

The TableListBox accessibility handler basically resolves to cell and then calls this

        const AccessibilityHandler* getCellHandler (int row, int column) const override
            if (isPositiveAndBelow (row, getNumRows()))
                if (isPositiveAndBelow (column, getNumColumns()))
                    if (auto* cellComponent = tableListBox.getCellComponent (tableListBox.getHeader().getColumnIdOfIndex (column, false), row))
                        return cellComponent->getAccessibilityHandler();

                if (auto* rowComp = tableListBox.getComponentForRowNumber (row))
                    return rowComp->getAccessibilityHandler();

            return nullptr;

which in my case fires for the RowComp and that’s a juce::ListBox::RowComponent

so I’m a bit stuck as to where I wedge my accesibility. Do I have to subclass all of the tablelistbox, replace the row class, make components which are that except for the AH, etc…?

Basically: For a read only table where I render it using paintCell is there a way to specify the cell level accesibility

For ListBox (as opposed to TableListBox) you get an option to override getRowName which the ListBox AH supports. But no such luck on the table.

Ideas welcome! Thanks as always!

The simplest approach I can think of atm is to override refreshComponentForCell to return a simple component, and to give that component whatever custom accessibility characteristics you require. It’s still a bit clunky, but hopefully less complex than reimplementing the RowComponent itself.

If that approach doesn’t work for whatever reason, please let us know and I can have a bit of a think about some other potential solutions.

1 Like

Just to follow up here, yes that did it. And the other trick (in my case) was using a tiny subclass of juce::Label for the thing I used as a cell component which just calls back into my original paintCell on the model and sets the accesibility value to the text in the cell (since this is read-only table).

As always happy to share pointers to code if people find this forum post a year form now or what not :slight_smile: