Skip to content

Commit fe42cd1

Browse files
committed
feat: add basic accessibility roles to library components
- NodeEditor: accessible-role list, labeled "Node Editor" - BaseNode: accessible-role list-item, description indicates selection state - Pin: accessible-role button, labeled by pin type (input/output) - Minimal example: sets accessible-label to node title Enables screen reader support and MCP introspection of the UI tree.
1 parent ae8e935 commit fe42cd1

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

examples/minimal/ui/minimal.slint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export { LinkData, DragState, NodeEditorInternalCallbacks, NodeEditorComputation
2121

2222
component SimpleNode inherits BaseNode {
2323
in property <string> title: "Node";
24+
accessible-label: title;
2425
// Set node size for BaseNode
2526
node-width: 250px;
2627
node-height: 80px;

node-editor-building-blocks.slint

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ export component BaseNode inherits Rectangle {
460460
in property <bool> selected: false;
461461
in property <length> world-x;
462462
in property <length> world-y;
463+
464+
// === Accessibility ===
465+
accessible-role: list-item;
466+
accessible-description: selected ? "selected" : "";
463467
// Persistent position offset (survives drag end until model updates)
464468
property <length> persistent-offset-x: 0px;
465469
property <length> persistent-offset-y: 0px;
@@ -669,6 +673,10 @@ export component Pin inherits Rectangle {
669673
in property <int> pin-id;
670674
in property <int> node-id; // Node this pin belongs to (for position reporting)
671675
in property <int> pin-type; // Type of pin (input/output/custom)
676+
677+
// === Accessibility ===
678+
accessible-role: button;
679+
accessible-label: pin-type == 1 ? "input pin" : pin-type == 2 ? "output pin" : "pin";
672680
in property <color> base-color: #888888;
673681
in property <color> hover-color: #aaaaaa;
674682
in property <length> base-size: 12px;

node-editor.slint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ export enum BoxSelectionModifier {
8484
/// Multiple editors in separate windows work fine. This limitation will be
8585
/// lifted once Slint introduces component-scoped globals.
8686
export component NodeEditor inherits FocusScope {
87+
// === Accessibility ===
88+
accessible-role: list;
89+
accessible-label: "Node Editor";
90+
8791
// === Shared viewport state ===
8892
in-out property <length> pan-x: 0px;
8993
in-out property <length> pan-y: 0px;

0 commit comments

Comments
 (0)