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 IAccessible2 labelled-by relation #17437

1 change: 1 addition & 0 deletions source/IAccessibleHandler/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ class RelationType(str, enum.Enum):
CONTROLLER_FOR = "controllerFor"
ERROR = "error"
ERROR_FOR = "errorFor"
LABELLED_BY = "labelledBy"
14 changes: 10 additions & 4 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Optional,
Tuple,
Union,
List,
)

from comtypes.automation import IEnumVARIANT, VARIANT
Expand Down Expand Up @@ -1162,13 +1161,20 @@ def isPointInObject(self, x, y):
return False
return True

def _get_labeledBy(self):
def _get_labeledBy(self) -> "IAccessible | None":
label = self._getIA2RelationFirstTarget(IAccessibleHandler.RelationType.LABELLED_BY)
if label:
return label

try:
(pacc, accChild) = IAccessibleHandler.accNavigate(
ret = IAccessibleHandler.accNavigate(
self.IAccessibleObject,
self.IAccessibleChildID,
IAccessibleHandler.NAVRELATION_LABELLED_BY,
)
if not ret:
return None
(pacc, accChild) = ret
obj = IAccessible(IAccessibleObject=pacc, IAccessibleChildID=accChild)
return obj
except COMError:
Expand Down Expand Up @@ -1940,7 +1946,7 @@ def _get_detailsRelations(self) -> Tuple["IAccessible"]:
# due to caching of baseObject.AutoPropertyObject, do not attempt to return a generator.
return tuple(detailsRelsGen)

def _get_controllerFor(self) -> List[NVDAObject]:
def _get_controllerFor(self) -> list[NVDAObject]:
control = self._getIA2RelationFirstTarget(IAccessibleHandler.RelationType.CONTROLLER_FOR)
if control:
return [control]
Expand Down
5 changes: 4 additions & 1 deletion user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ Add-ons will need to be re-tested and have their manifest updated.
* Removed the requirement to indent function parameter lists by two tabs from NVDA's Coding Standards, to be compatible with modern automatic linting. (#17126, @XLTechie)
* Added the [VS Code workspace configuration for NVDA](https://nvaccess.org/nvaccess/vscode-nvda) as a git submodule. (#17003)
* In the `brailleTables` module, a `getDefaultTableForCurrentLang` function has been added (#17222, @nvdaes)
* Retrieving the `labeledBy` property now works for UIA elements supporting the corresponding `LabeledBy` UIA property. (#17442, @michaelweghorn)
* Retrieving the `labeledBy` property now works for:
* objects in applications implementing the `labelled-by` IAccessible2 relation. (#17436, @michaelweghorn)
* UIA elements supporting the corresponding `LabeledBy` UIA property. (#17442, @michaelweghorn)


#### API Breaking Changes

Expand Down