Fix screen reader names of ComboBoxes and their items

KE
12d ago
+192-3

Part of #1919 (screen reader support). This PR only covers dropdowns (ComboBox), so it is not meant to close that issue.

Problem

  • Data-bound ComboBox items were announced by their type name, e.g. Flow.Launcher.Core.Resource.Language or System.Windows.Media.FamilyTypeface. When AutomationProperties.Name is not set, WPF names the item container after the item's ToString(). That affects both the open list and the selected value a screen reader reads on a closed ComboBox.
  • ComboBoxes that are not the direct Content of a SettingsCard had no accessible name at all, e.g. the language selector, which sits in a StackPanel next to the "Help us translate" link. iNKORE's SettingsCard.SetAccessibleContentName only names its direct content, from a string Header.

Changes

Using the WPF UI Automation properties (AutomationProperties.Name / AutomationProperties.LabeledBy):

  • Item names: an ItemContainerStyle sets AutomationProperties.Name on each ComboBoxItem, bound to the same property that is displayed (Display, DisplayName, Description, or the typeface's AdjustedFaceNames[en-us]). The styles are based on iNKORE's DefaultComboBoxItemStyle, so the look is unchanged. Shared styles are in SettingWindowStyle.xaml. The bundled plugins define their own copy, so they don't depend on a new host resource key.

  • ComboBox names: AutomationProperties.LabeledBy where a visible label element exists. Otherwise AutomationProperties.Name="{DynamicResource …}" with the same localized string as the card header, so the name follows runtime language changes. This also covers ComboBoxes that are direct SettingsCard content. iNKORE's SettingsCard already names those from Header, but only once in OnApplyTemplate, so after a runtime language switch the name used to stay in the previous language.

  • New strings (en only): queryBoxFontStyle, resultItemFontStyle, resultSubItemFontStyle, and in Explorer plugin_explorer_previewpanel_date_format_label / plugin_explorer_previewpanel_time_format_label.

  • Language changes: after a language change, the ComboBox text and the item names used to keep the previous language in two places:

    • DropdownDataGeneric.Display now raises PropertyChanged. UpdateLabels rewrites it in place, and the generated *Localized classes already notified.
    • Explorer's EnumBindingModel now derives from BaseModel and has an UpdateLabels that raises PropertyChanged for Description. OnCultureInfoChanged calls it for the three engine lists, so the option objects and the current selection are kept.

Apart from these two small C# changes, the changes are XAML only.

Tested with NVDA

Tested manually with NVDA on the CI build of this branch (1.20.2.1), with the UI in Traditional Chinese:

WhereComboBoxNVDA reads
Welcome wizardLanguage「語言 下拉式方塊 系統」 (Language, combo box, System). Items: 系統, English, 中文, 中文(繁体). After selecting, it reads 中文(繁体)
Settings → GeneralSearch Window Location「搜尋視窗位置 下拉式方塊 帶有滑鼠游標的顯示器」 (… Monitor with Mouse Cursor)
Settings → GeneralSearch Window Position on Monitor「搜尋視窗在螢幕上的位置 下拉式方塊 置中」 (… Center)
Settings → GeneralQuery Search Precision「查詢搜尋精確度 下拉式方塊 一般」 (… Regular)
Settings → GeneralLast Query Style「最後查詢樣式 下拉式方塊 選擇上一個查詢」 (… Select last query)
Settings → GeneralHistory Style「History Style 下拉式方塊 Query history」. Items: Query history, Last opened history

History Style is read in English because that string has no zh-TW translation yet.

The other changed ComboBoxes have not been tested with a screen reader yet. They were checked with a script that hosts the edited XAML and reads it through the UI Automation client:

  • Settings → General: language, custom monitor number, Dialog Jump (window position, result behaviour, file result behaviour), Double Pinyin schema
  • Settings → Theme: query box / result title / result subtitle font and font style, backdrop type, clock format, date format, animation speed, color scheme, code highlight theme
  • Settings → About: log level, setting window font
  • Settings → Plugins: display mode filter. Plugin Store: sort mode
  • Default browser and default file manager windows
  • Plugin settings: Calculator (including the new history creation mode from #4454), Explorer, Web Search, Shell, Browser Bookmark

Not in this PR (next steps for #1919)

  • Other controls still lack accessible names, e.g. the sliders in the theme size editor (ui:ControlHelper.Header does not set a name) and text boxes such as the custom window position and custom animation length.
  • Found during the NVDA test:
    • Welcome wizard: the Next and Back buttons contain only an icon and are read as just "button".
    • Settings → General: the toggle switch in the header of the "Start Flow Launcher on system startup" expander is read without a name. iNKORE's SettingsExpander names only itself, not its Content, so every SettingsExpander header toggle is probably affected.

🤖 Generated with Claude Code