Skip to content

Commit 263c3c8

Browse files
Merge 0561973 into f0b3626
2 parents f0b3626 + 0561973 commit 263c3c8

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

source/IAccessibleHandler/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ class RelationType(str, enum.Enum):
2929
CONTROLLER_FOR = "controllerFor"
3030
ERROR = "error"
3131
ERROR_FOR = "errorFor"
32+
LABELLED_BY = "labelledBy"

source/NVDAObjects/IAccessible/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
Optional,
1010
Tuple,
1111
Union,
12-
List,
1312
)
1413

1514
from comtypes.automation import IEnumVARIANT, VARIANT
@@ -1162,13 +1161,20 @@ def isPointInObject(self, x, y):
11621161
return False
11631162
return True
11641163

1165-
def _get_labeledBy(self):
1164+
def _get_labeledBy(self) -> "IAccessible" | None:
1165+
label = self._getIA2RelationFirstTarget(IAccessibleHandler.RelationType.LABELLED_BY)
1166+
if label:
1167+
return label
1168+
11661169
try:
1167-
(pacc, accChild) = IAccessibleHandler.accNavigate(
1170+
ret = IAccessibleHandler.accNavigate(
11681171
self.IAccessibleObject,
11691172
self.IAccessibleChildID,
11701173
IAccessibleHandler.NAVRELATION_LABELLED_BY,
11711174
)
1175+
if not ret:
1176+
return None
1177+
(pacc, accChild) = ret
11721178
obj = IAccessible(IAccessibleObject=pacc, IAccessibleChildID=accChild)
11731179
return obj
11741180
except COMError:
@@ -1940,7 +1946,7 @@ def _get_detailsRelations(self) -> Tuple["IAccessible"]:
19401946
# due to caching of baseObject.AutoPropertyObject, do not attempt to return a generator.
19411947
return tuple(detailsRelsGen)
19421948

1943-
def _get_controllerFor(self) -> List[NVDAObject]:
1949+
def _get_controllerFor(self) -> list[NVDAObject]:
19441950
control = self._getIA2RelationFirstTarget(IAccessibleHandler.RelationType.CONTROLLER_FOR)
19451951
if control:
19461952
return [control]

user_docs/en/changes.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ Add-ons will need to be re-tested and have their manifest updated.
103103
* 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)
104104
* Added the [VS Code workspace configuration for NVDA](https://nvaccess.org/nvaccess/vscode-nvda) as a git submodule. (#17003)
105105
* In the `brailleTables` module, a `getDefaultTableForCurrentLang` function has been added (#17222, @nvdaes)
106-
* Retrieving the `labeledBy` property now works for UIA elements supporting the corresponding `LabeledBy` UIA property. (#17442, @michaelweghorn)
106+
* Retrieving the `labeledBy` property now works for:
107+
* objects in applications implementing the `labelled-by` IAccessible2 relation. (#17436, @michaelweghorn)
108+
* UIA elements supporting the corresponding `LabeledBy` UIA property. (#17442, @michaelweghorn)
109+
107110

108111
#### API Breaking Changes
109112

0 commit comments

Comments
 (0)