Class AccessibilityUtil
java.lang.Object
com.dlsc.gemsfx.util.AccessibilityUtil
Small helper methods used by the GemsFX controls to add a baseline of
accessibility metadata (screen-reader support).
The GemsFX convention is:
- every user-facing control sets an
AccessibleRolein its constructor, and - value-bearing controls derive their
accessibleTextfrom their own state.
accessibleText helpers deliberately yield to application code: once an
application explicitly calls Node.setAccessibleText(String) with a value that this
class did not write, the automatic updates stop so the application value always wins.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidbindAccessibleText(javafx.scene.Node node, javafx.beans.value.ObservableValue<String> source) Keeps theaccessibleTextof the given node in sync with the value of the given observable, without overriding a value that the application has set itself.static voidsetRole(javafx.scene.Node node, javafx.scene.AccessibleRole role) Sets the accessible role on the given node.static voidSets the accessible role and role description on the given node.
-
Method Details
-
setRole
public static void setRole(javafx.scene.Node node, javafx.scene.AccessibleRole role) Sets the accessible role on the given node.- Parameters:
node- the node, may benull(ignored)role- the accessible role
-
setRole
public static void setRole(javafx.scene.Node node, javafx.scene.AccessibleRole role, String roleDescription) Sets the accessible role and role description on the given node. The role description is a short, localized, human-readable name for the type of control (for example "avatar").- Parameters:
node- the node, may benull(ignored)role- the accessible roleroleDescription- a human-readable description of the role
-
bindAccessibleText
public static void bindAccessibleText(javafx.scene.Node node, javafx.beans.value.ObservableValue<String> source) Keeps theaccessibleTextof the given node in sync with the value of the given observable, without overriding a value that the application has set itself.The node's accessible text is updated whenever the source changes, but only as long as the current accessible text is still the value this method last wrote (or is empty). As soon as application code sets a different accessible text, the automatic updates stop.
- Parameters:
node- the node whose accessible text should be maintained, may benullsource- the observable providing the accessible text
-