Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UIA LabeledBy property #17443

Merged

Commits on Nov 26, 2024

  1. Support UIA LabeledBy property

     ### Link to issue number:
    
    Fixes nvaccess#17442
    
     ### Summary of the issue:
    
    UIA has a `UIA_LabeledByPropertyId` property, see https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids :
    
    > Identifies the LabeledBy property, which is an automation element that contains the text label for this element.
    > This property can be used to retrieve, for example, the static text label for a combo box.
    > Variant type: VT_UNKNOWN
    > Default value: NULL
    
    However, that one was so far not taken into account by NVDA's "labeledBy" property for UIA elements.
    
     ### Description of user facing changes
    
    In NVDA's Python console, retrieving the "labeledBy" property now works for UIA elements supporting the corresponding LabeledBy UIA property.
    
     ### Description of development approach
    
    Override `NVDAObject._get_labeledBy` in UIA to retrieve and return the UIAElement reported by the `UIA_LabeledByPropertyId` property.
    
     ### Testing strategy:
    
    1. start NVDA
    2. build Qt's qtbase module including an additional change that implements support for `UIA_LabeledByPropertyId` in Qt ( https://codereview.qt-project.org/c/qt/qtbase/+/606710 )
    3. run Qt's "calendarwidgets" sample app (`qtbase/examples/widgets/widgets/calendarwidget/calendarwidget.exe`)
    4. move focus to the "Locale" combobox
    5. open NVDA's Python console (Ctrl+Insert+Z)
    6. print the object that the currently focused edit is labelled by and
       some of its properties:
    
        >>> focus.labeledBy
        <NVDAObjects.UIA.UIA object at 0x0BE47ED0>
        >>> focus.labeledBy.name
        'Locale'
        >>> focus.labeledBy.role
        <Role.STATICTEXT: 7>
    
     ### Known issues with pull request:
    
    None
    
     ### Code Review Checklist:
    
    - [x] Documentation:
      - Change log entry
      - User Documentation
      - Developer / Technical Documentation
      - Context sensitive help for GUI changes
    - [x] Testing:
      - Unit tests
      - System (end to end) tests
      - Manual testing
    - [x] UX of all users considered:
      - Speech
      - Braille
      - Low Vision
      - Different web browsers
      - Localization in other languages / culture than English
    - [x] API is compatible with existing add-ons.
    - [x] Security precautions taken.
    
    <!-- Please keep the following -->
    @coderabbitai summary
    michaelweghorn committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    7ee9bce View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2024

  1. Annotate return type

    Requires `from __future__ import annotations` for Python < 3.14
    to use `UIA` return type in the UIA class itself,
    see https://peps.python.org/pep-0563/
    and https://peps.python.org/pep-0649/
    michaelweghorn committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    b82c5c0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2632de3 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2024

  1. Configuration menu
    Copy the full SHA
    d6528ad View commit details
    Browse the repository at this point in the history