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"
15 changes: 11 additions & 4 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

from __future__ import annotations
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
import typing
from typing import (
Generator,
Optional,
Tuple,
Union,
List,
)

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

def _get_labeledBy(self):
def _get_labeledBy(self) -> IAccessible | None:
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
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 +1947,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) -> typing.List[NVDAObject]:
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
control = self._getIA2RelationFirstTarget(IAccessibleHandler.RelationType.CONTROLLER_FOR)
if control:
return [control]
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ 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 objects in applications implementing the "labelled-by" IAccessible2 relation and no longer triggers an error. (#17436, @michaelweghorn)
seanbudd marked this conversation as resolved.
Show resolved Hide resolved

#### API Breaking Changes

Expand Down