Repository navigation
Conversation
Classic UI Automation has no Switch control type, and the Windows adapter did not implement IScrollProvider for the scroll fields the schema already defines. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for this; we need the scroll pattern for FLUI and carried a patch of our own until a release has one. Three things we ran into, in case they help: Intermediate overflow. scroll_percent, scroll_view_size and offset_for_scroll_percent compute max - min, which is infinite for a range wider than f64::MAX (an unbounded list publishing -1e308..1e308, say): the percentage becomes 0 or NaN, the view size 0, and SetScrollPercent asks for an infinite offset. Halving before subtracting keeps it finite: (pos / 2.0 - min / 2.0) / (max / 2.0 - min / 2.0), and the target as a weighted sum, min * (1.0 - t) + max * t. |
Summary
This pull request was implemented by an AI agent (Agent).
Role::Switchstays a UI Automation Button because classic UI Automation has no Switch control type. The localized control type isswitch, so a screen reader can announce a switch instead of only a button.ScrollPatternis implemented from existing scroll offsets and directional actions so assistive technology can scroll the container, not onlyScrollIntoView.Localized control type
role_descriptionremains the localization hook (aria-roledescription). When a node sets it, that string is still the localized control type. The Windows adapter has no string catalog of its own. ForRole::Switchwith norole_description, the localized control type is the English tokenswitch, the same string this adapter already returns as the ARIA role. A toolkit that has a translated name can setrole_description. This change does not invent a translated control type or a new UIA control type.ScrollPattern
The shared schema already has
scroll_x/scroll_y(with min and max),Action::ScrollUp,ScrollDown,ScrollLeft, andScrollRightwithActionData::ScrollUnit, andAction::SetScrollOffset. No parallel event protocol was added.(current - min) / (max - min) * 100, orUIA_ScrollPatternNoScrollwhen that axis has no range.scroll_*_max - scroll_*_minas the hidden remainder:100 * viewport / (viewport + range). There is no separate viewport field in the schema. If the bounds or the range are missing, the view size is reported as 100 rather than inventing a content size.IScrollProvider::ScrollmapsScrollAmountonto the existing directional actions. Small amounts useScrollUnit::Itemand large amounts useScrollUnit::Page. Increment moves toward a larger scroll offset.SetScrollPercentmaps toAction::SetScrollOffsetwhen that action is supported.UIA_ScrollPatternNoScroll(-1) leaves that axis unchanged. If the node does not supportSetScrollOffset, the call returnsUIA_E_NOTSUPPORTED.The pattern is exposed when an axis has a positive scroll range or a directional scroll action. That includes
Role::ScrollViewand other roles that carry the same fields, such as a list.Action::ScrollIntoViewby itself still only enablesScrollItemPattern.Verification
cargo test -p accesskit_windows -- --test-threads=1: 19 passed, 0 failed, including window teststests::simple::has_native_uia,navigation,focus, andtests::subclassed::has_native_uia,double_instantiate.cargo clippy -p accesskit_windows --all-targets -- -D warnings: no warnings.NVDA 2026.1.1, eSpeak NG 1.52.0, spoken lines:
Speaking ['Night mode', 'toggle button', 'not pressed'];Speaking ['Inbox offset 40'];Speaking ['Inbox offset 100']. UIA control type remained Button (50000). Localized control type wasswitch.Scroll(NoAmount, SmallIncrement)moved vertical percent 0 to 20 (offset 40).SetScrollPercent(NoScroll, 50)set offset 100 and vertical percent 50.Narrator speech history:
AccessKitSwitchScroll 区域, Night mode, switch, 关闭andInbox offset 0. Narrator used the localized control typeswitch. NVDA and Narrator were quit afterward.If this implementation style does not match project requirements, maintainers can ask for changes and the author will update the pull request, or they can close the pull request directly. Either outcome is fine.