expose toggle switches to screen readers with their state and a name taken from the enclosing form field
What changed, and why it matters
This commit improves accessibility for blind and low-vision users who rely on screen readers. It gives on/off toggle switches a readable label and tells screen readers whether the switch is currently on or off. There is no security issue here.
No security action needed. Treat as a normal accessibility improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies UnlabeledToggleSwitch to expose JavaFX accessibility attributes (AccessibleRole.TOGGLE_BUTTON, AccessibleAttribute.SELECTED/TEXT, AccessibleAction.FIRE) and derives a name from the enclosing tornadofx Field when no explicit accessibleText is set. It also adds accessibleText=”Server connection” to two server toggle instances in FXML. This is an a11y/usability fix with no security-relevant code changes.
Changed components
UnlabeledToggleSwitch controlapp.fxml server togglewelcome.fxml server toggleInspect captured patch +42 / −2
### src/main/java/com/sparrowwallet/sparrow/control/UnlabeledToggleSwitch.java
@@ -1,10 +1,20 @@
package com.sparrowwallet.sparrow.control;
import impl.org.controlsfx.skin.ToggleSwitchSkin;
+import javafx.scene.AccessibleAction;
+import javafx.scene.AccessibleAttribute;
+import javafx.scene.AccessibleRole;
+import javafx.scene.Parent;
import javafx.scene.control.Skin;
import org.controlsfx.control.ToggleSwitch;
+import tornadofx.control.Field;
public class UnlabeledToggleSwitch extends ToggleSwitch {
+ public UnlabeledToggleSwitch() {
+ setAccessibleRole(AccessibleRole.TOGGLE_BUTTON);
+ selectedProperty().addListener((observable, oldValue, newValue) -> notifyAccessibleAttributeChanged(AccessibleAttribute.SELECTED));
+ }
+
@Override protected Skin<?> createDefaultSkin() {
return new ToggleSwitchSkin(this) {
@Override
@@ -13,4 +23,34 @@ protected double computePrefWidth(double height, double topInset, double rightIn
}
};
}
+
+ @Override
+ public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
+ if(attribute == AccessibleAttribute.SELECTED) {
+ return isSelected();
+ } else if(attribute == AccessibleAttribute.TEXT) {
+ Object text = super.queryAccessibleAttribute(attribute, parameters);
+ if(text instanceof String str && !str.isEmpty()) {
+ return text;
+ }
+
+ //Without its own text, the switch is named by the form field it sits in
+ for(Parent parent = getParent(); parent != null; parent = parent.getParent()) {
+ if(parent instanceof Field field && field.getText() != null) {
+ return field.getText().replaceAll(":$", "");
+ }
+ }
+ }
+
+ return super.queryAccessibleAttribute(attribute, parameters);
+ }
+
+ @Override
+ public void executeAccessibleAction(AccessibleAction action, Object... parameters) {
+ if(action == AccessibleAction.FIRE) {
+ fire();
+ } else {
+ super.executeAccessibleAction(action, parameters);
+ }
+ }
}
### src/main/resources/com/sparrowwallet/sparrow/app.fxml
@@ -185,7 +185,7 @@
<StatusBar fx:id="statusBar" text="" minHeight="36">
<rightItems>
- <UnlabeledToggleSwitch fx:id="serverToggle">
+ <UnlabeledToggleSwitch fx:id="serverToggle" accessibleText="Server connection">
<tooltip>
<Tooltip text="Disconnected" />
</tooltip>
### src/main/resources/com/sparrowwallet/sparrow/welcome.fxml
@@ -64,7 +64,7 @@
<Region VBox.vgrow="ALWAYS" />
<StatusBar fx:id="serverStatus">
<rightItems>
- <UnlabeledToggleSwitch fx:id="serverToggle" />
+ <UnlabeledToggleSwitch fx:id="serverToggle" accessibleText="Server connection" />
</rightItems>
</StatusBar>
</VBox>Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.