delphiaccessibilityc++buildervirtualtreeview

How to use TVirtualStringTree AccessibleName or implement accessibility?


I can see that TVirtualStringTree has a property called AccessibleName yet, I don't see it working, that is, giving the string which is set to screen reader such as NVDA.

What I tried is setting this in the OnGetText event but that doesn't seem to produce any results (e.g. Sender->AccessibleName = "my node name";). All it reads is entire contents of the tree, not just a current node just the same as if I didn't make any change to the property, and if node is changed (using keyboard) it doesn't do anything.

What it should be reading is - Column name - column content - another column name - another column content etc. like it does with the regular TListView.

There seems to be an implementation of iAccessible interface here - https://github.com/Virtual-TreeView/Virtual-TreeView/blob/master/Source/VTAccessibility.pas

Can you share some example how to use VirtualTreeView built in accessibility to make the component readable to screen readers as it seems that such examples are really scarce?

Edit (for future googlers):

Related question which solves the C++ Builder accessiblity unit linking:

Implementing VirtualTreeView TVTDefaultAccessibleProvider in C++ Builder

Edit 2 (for future googlers):

Additionally, TVirtualStringTree also provides OnGetImageText. This event is used to provide accessible text for images used in the tree, for example if you have multiple images in a node to represent certain states you can describe these states with image labels.


Solution

  • You need to add VirtualTrees.Accessibility unit to the uses section (project or one of your units). This unit registers accessibility providers, it will read only the focused item in the tree along with column names.