JFLib

plat/apple_ios_a11y.rs (Apple)#

Source: lib/plat/apple_ios_a11y.rs

apple_ios_a11y -- (a11y.rs) the accessibility tree as UIAccessibility elements (VoiceOver on the
iPhone, docs/VOICEOVER.md VO4)

  start(app)                 VoiceOver (or Switch Control) running turns a11y::active() on, its
                             notification follows it; a question to the view turns it on too
  view_methods()             (apple_ios.rs) JFView's accessibility: not an element itself, its
                             elements are the nodes of the shown windows; the Escape gesture
  changed(snapshot, changes) the UI published a new tree: layout / screen changed notifications
  ios_ax_tree / ios_ax_act   (tests, any thread) read and drive the elements as VoiceOver does,
                             on the main thread

Every node is an object of our class JFAXIosElement (a subclass of UIAccessibilityElement), made
on demand and kept while its node exists; text boxes are JFAXIosText, which adds UITextInput
(apple_ios_text.rs).  The canvas holds all windows (web_windows.rs): a node's frame is its
window's place in the canvas plus its rectangle, in points of JFView (px / the host's scale),
converted to the screen.  Lists, tab strips, dialogs, menus and titled boxes are containers
(not elements themselves; their nodes are their elements); every other node is an element, and
what hangs below it (the popup of a drop-down) follows it in its container.  A modal dialog
window shows alone (accessibilityViewIsModal).  Actions become a11y::request and run a frame at
once, so that VoiceOver reads the new value right after it asked for it.

Traits: Label static text; Heading header; Button, MenuItem, a menu bar entry, Combo button
(pressed: selected); CheckBox, Radio button, selected when on; Switch toggle button (iOS 17, else
button) with the value 1 / 0; Slider adjustable (5 % of the range per swipe, as Android);
Progress updates frequently, the value in percent; Link link; ListItem, Tab button, selected;
Image image; disabled: not enabled.  Containers: a list a list, a tab strip a tab bar, the rest
semantic groups with their names.
  • struct IosAxElem an element as VoiceOver reads it (UIAccessibility)

    • depth: u32 -- containers above it
    • element: bool -- isAccessibilityElement (false: a container)
    • label: String
    • value: String
    • ident: String
    • traits: Vec<&'static str> -- the traits by name: button, link, header, image, selected, static, disabled, frequent, adjustable, tabbar, keyboard, toggle
    • container: isize -- UIAccessibilityContainerType
    • modal: bool
    • frame: [f64; 4] -- screen points
    • text_input: bool -- it conforms to UITextInput (a text field to VoiceOver)
  • enum IosAxAct an action of a test

    • Activate -- a double tap (accessibilityActivate)
    • Increment
    • Decrement
  • fn ios_ax_tree() -> Option<Vec<IosAxElem>> (tests, any thread) the accessibility objects of the view as VoiceOver reads them (None: no view yet)

  • fn ios_ax_act(label: &str, tr: &str, a: IosAxAct) -> bool (tests, any thread) the element with this label (and trait tr, IosAxElem::traits; "": any): an action as VoiceOver takes it -> the element's answer (accessibilityActivate) / whether it is adjustable

  • fn ios_ax_escape() -> bool (tests, any thread) VoiceOver's Escape gesture on the view

  • fn ios_ax_listen(on: bool) (tests) note the notifications the bridge posts from now on (false: stop)

  • fn ios_ax_events() -> Vec<String> (tests) the notifications noted since the last call: "LayoutChanged:Name"

  • enum IosAxText a question of a test about a text field's text (UITextInput of its element)

    • Selected -- the selected range: "location,length" (UTF-16)
    • Text(usize, usize) -- the text of a UTF-16 range
    • Caret(usize) -- the caret's rectangle at an offset, screen points "x,y,w,h"
  • fn ios_ax_text(label: &str, q: IosAxText) -> Option<String> (tests, any thread) ask the text field with this label as VoiceOver does

  • fn ios_ax_select(label: &str, a: usize, n: usize) -> bool (tests, any thread) select UTF-16 a .. a + n in the text field with this label (UITextInput)

  • fn ios_ax_type(t: &str) -> bool (tests, any thread) the keyboard's view types text (UIKeyInput / UITextInput of JFView)

Source: docs/API.md in the JFLib repository.