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 overwritten to handle additional attributes. For example, Parent overrides queryAccessibleAttribute() to answer to “CHILDREN”, Button override queryAccessibleAttribute() to answer to “TITILE”. When queryAccessibleAttribute() is overwritten it is important to call super at the end. Node#notifyAccessibleAttributeChanged() is final.
Implementation (low level)
The first time the OS requests JavaFX for accessibility we forward this request all the way to Scene#getAccessible()
In Win32,
- 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()
In 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
Note that in GlassView3D.m the accessibilityAttributeName() is sent to the NSView, which correctly answers the AT.
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 get in the way of “accessibilityAttributeValue()” when the attribute is “NSAccessibilityChildrenAttribute” in order to add the accessible of Scene#getRoot() to the otherwise empty list of children known by the NSView. Scene#getAccessible(), in the handling of the CHILDREN case, is where it happens.
Note that any element in the scene graph (Node and its subclasses and Scene) are always handled by the same type of Accessible, which is always handled by the same type of GlassAccessible. The mapping of these types is always 1 to 1:
Scene Graph | Glass Java | Glass Native |
---|---|---|
Nodes/Scene | MacAccessible.java, WinAccessible.java | GlassAccessible.m, GlassAccessible.cpp |
JFX does not different implementation of accessible for different nodes, whatever it is a button or the scene they use the same accessible implementation to return data back and forward to the OS.
There is, however, one important difference. The Accessible linked to the Scene is the only one where "getView() != null”, and it answer back to the OS differently in some cases. It is only real object the OS sees (as it has a native element associated with it, a HWND or a NSView).
All the other Accessible, which return NULL in getView(), starting at the scene’s root, are lightweight as far the OS is concerned.
Another design decision:
All the logics how to handle OS request is implemented in Accessible, here it does whatever dance is necessary to map these requests into calls to the public API and to map the results back.
The GlassAccessible (the native side) has no control logic in it, it basically gets from the OS, convert data types, call Accessible and convert the result back.
As much as possible, using basic types. One to one JNI mapping.
Note that GlassAccessible.m/MacAccessible implement NSAccessible entirely so that it can any request from the OS.
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 released the Accessible object when the node is removed from the Scene.