Public API
Attribute (enum)
Action (enum)
Roles (enum)
Accessible (class)
Object getAttribute(Attribute) - Call by the AT to returned the current value for the given attribute
setAttribute(Attribute, Object) - Call by the AT to set the given attribute to the given value [*** NOT IMPLEMENT YET ***]
sendNotification(Attribute) - Call by the Node to notify the AT that attribute has changed
executeAction(Action) - Call by the AT to
Scene#getAccessible() - This is the “root accessible”, it is special case, more on it later. It shouldn’t matter for control developer anyway.
Node#getAccessible() - lazily create an accessible and forward all its requested to the Node, for example:
Accessible#getAttribute -> Node#accGetAttribute, Accessible#executeAction -> Node#accExecuteAction, and so on
Subclasses of node override #accGetAttribute() to add more attributes to it. For example, Parent overrides accGetAttribute() to answer to “Children”, Button override accGetAttribute() to answer to “Title”. When accGetAttribute is overwritten it is important to call super at the end. Excepted by Node, no other Nodes reference Accessible directly.
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()
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()
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 handle the same type of Accessible, which is always handled by the same type of PlatformAccessible, which is always handled by the same type of GlassAccessible. The mapping of these types is always 1 to 1:
Scene | Glass Java | Glass Native |
---|---|---|
Node->Accessible | PlatformAccessible: MacAccessible, WinAccessible | GlassAccessible GlassAccessible.m, GlassAccessible.cpp |
I do not have 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 PlatformAccessible that 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 wit it, a HWND or a NSView).
All the other PlatformAccessible (getView() == NULL), 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 PlatformAccessible, 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 PlatformAccessible and convert the result back.
As much as possible, using basic types. One to one JNI mapping.
Note that GlassAccessible.m/MacAccessible shall 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).