Public API
Types
- enum javafx.scene.AccessibleAction
- enum javafx.scene.AccessibleAttribute
- enum javafx.scene.AccessibleRole
Properties
- Node#role
- Node#roleDescription
- Node#accessibleText
- Node#accessibleHelp
Methods
- Node#queryAccessibleAttribute(AccessibleAttribute, Object...)
- Call by the AT to returned the current value for the given attribute
- Node#notifyAccessibleAttributeChanged(AccessibleAttribute)
- Call by the Node to notify the AT that attribute has changed
- Call by the Node to notify the AT that attribute has changed
- Node#executeAccessibleAction(AccessibleAction, Object)
- Call by the AT to execute the given action
- Call by the AT to execute the given action
Node#queryAccessibleAttribute() and Node#executeAccessibleAction() are often over-ridden to handle additional attributes. For example, Parent overrides queryAccessibleAttribute() to answer to “CHILDREN”, Button overrides queryAccessibleAttribute() to answer to “TITILE”. When queryAccessibleAttribute() is over-ridden it is important to call the super for attributes that are not handled so that the default value for the attribute is returned.
Node#notifyAccessibleAttributeChanged() is final.
Implementation (low level)
The first time the operating system requests any accessibility functionality, Scene#getAccessible() is called:
On Windows:
- GlassWindow.cpp#WindowProc for WM_GETOBJECT
- ViewContainer.cpp#HandleViewGetAccessible()
- View.java#getAccessible()
- (GlassViewEventHandler)EventHandler#getSceneAccessible()
- GlassScene#TKSceneListener#getSceneAccessible()
- Scene#ScenePeerListener#getSceneAccessible()
- Scene#getAccessible()
- Scene#ScenePeerListener#getSceneAccessible()
- GlassScene#TKSceneListener#getSceneAccessible()
- (GlassViewEventHandler)EventHandler#getSceneAccessible()
- View.java#getAccessible()
- ViewContainer.cpp#HandleViewGetAccessible()
On Mac:
- GlassView3D.m#accessibilityAttributeName (as well other methods defined in NSAccessible)
- GlassViewDelegate.m#getAccessible
- View.java#getAccessible()
- (GlassViewEventHandler)EventHandler#getSceneAccessible()
- GlassScene#TKSceneListener#getSceneAccessible()
- Scene#ScenePeerListener#getSceneAccessible()
- Scene#getAccessible()
- Scene#ScenePeerListener#getSceneAccessible()
- GlassScene#TKSceneListener#getSceneAccessible()
- (GlassViewEventHandler)EventHandler#getSceneAccessible()
- View.java#getAccessible()
- GlassViewDelegate.m#getAccessible
In GlassView3D.m the accessibilityAttributeName() is sent to the NSView the first time accessibility functionality is needed. We don’t need to change anything on the way NSView handles accessibilityAttributeName(). We just use it as hook to initialize our a11y.
We do, however, need to intercept “accessibilityAttributeValue()” when the attribute is “NSAccessibilityChildrenAttribute” in order to add the operating system accessible of Scene#getRoot() to the otherwise empty list of children known by the NSView. This happens in Scene#getAccessible(), in the handling of the CHILDREN case.
For any Node in the scene graph, there is exactly one operating system accessible object.
Scene Graph | Glass Java | Glass Native |
---|---|---|
Nodes/Scene | MacAccessible.java, WinAccessible.java | GlassAccessible.m, GlassAccessible.cpp |
FX does not have different implementations of operating system accessible objects for different nodes. A button or a list control each have a different instance of the operating system object, but these are all instances of Accessible (ie. there is no ButtonAccessible or ListAccessible).
There is, however, one important difference. The Accessible linked to the Scene is the only one where "getView() != null”, and it answers back to the operating system differently in some cases (as it has a native element associated with it, an HWND or a NSView).
All the other Accessible objects, which return NULL in getView(), starting at the scene’s root, are lightweight as far the OS is concerned.
Another design decision:
All the logic about how to handle operating system request is implemented in Accessible. Accessible maps these requests into calls to the public API and to map the results back to native object that the operating system requires.
The GlassAccessible (the native side) has no FX Control logic in it. It gets requests from the operating system, convert data types, calls into Java using the Accessible class and converts the result.
As much as possible in the implementation, using basic types, there is a one to one JNI mapping between names and concepts that the operating system uses.
Note that GlassAccessible.m/MacAccessible implement NSAccessible entirely so that it can handle any request from the operating system.
The same is true for GlassAccessible.cpp/WinAccessible, it implements IRawElementProviderSimple, IRawElementProviderFragment, IRawElementProviderFragmentRoot, IInvokeProvider, ISelectionProvider, ISelectionItemProvider, etc (whatever is needed to cover JavaFX).
Accessible objects are created by the Node, only when requested by the screenreader, in #getAccessible(). Node releases the Accessible object when the node is removed from the Scene.