Skip to content

Expose the content of text inputs to assistive technologies - #12750

Open
DataTriny wants to merge 3 commits into
slint-ui:masterfrom
DataTriny:accesskit-text
Open

Expose the content of text inputs to assistive technologies#12750
DataTriny wants to merge 3 commits into
slint-ui:masterfrom
DataTriny:accesskit-text

Conversation

@DataTriny

Copy link
Copy Markdown
Contributor

Closes #2895

Allows assistive technologies to see the textual content of text inputs, navigate it, do hit testing, inspect the selection and manipulate it.

This will later need to be generalized to rich/styled text and Markdown content, but I feel like the current parley API is not flexible enough. I have filed linebender/parley#716 but I have no idea how it will turn out.

Part of AccessKit/accesskit#565

Adds an `accessibility-text` feature on `i-slint-core` that turns on parley's
`accesskit` feature plus the `accesskit` crate dependency.
Winit's existing `accessibility` feature propagates it.
Describes a `TextInput`'s content to an assistive technology per character
rather than as one opaque value: `RendererSealed::visit_text_input_layout` lends
the accessibility pass the very layout the renderer draws with, and
`sharedparley::accessibility` turns it into AccessKit TextRun children, keeping
`LayoutAccessibility` across passes so NodeIds survive an edit.

A renderer with no parley layout to lend -- the software renderer with bitmap
fonts, or with `SLINT_SOFTWARE_RENDERER_PARLEY_DISABLED` set -- reports so, and
the value is still published; only the caret and selection go unreported, since
a `TextSelection` names TextRun nodes that don't exist.

ChangeLog: Exposed the content of text inputs to assistive technologies.
`decode_selection` resolves an incoming `SetTextSelection` against the layout,
so its offsets index the text the input displays. `set-selection-offsets`
indexes the text it holds. For a password field those are different strings:
the mask character is three bytes in UTF-8 where the characters it stands in for
are usually one, so selecting anything past the first character landed the
anchor and cursor in the wrong place.

Convert on the way out, the way
`map_byte_offset_from_visual_text_to_actual_text` does for hit-testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility: Support text input widgets

1 participant