Skip to content

Commit 4e4c4f5

Browse files
authored
Merge 1923005 into 41418d7
2 parents 41418d7 + 1923005 commit 4e4c4f5

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

source/NVDAObjects/__init__.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,19 +316,30 @@ def findOverlayClasses(self, clsList: typing.List[typing.Type["NVDAObject"]]) ->
316316

317317
beTransparentToMouse = False #:If true then NVDA will never consider the mouse to be on this object, rather it will be on an ancestor.
318318

319+
def objectFromPointRedirect(self, x: int, y: int) -> "NVDAObject | None":
320+
"""Redirects NVDA to another object if this object is retrieved from on-screen coordinates.
321+
:param x: the x coordinate.
322+
:param y: the y coordinate.
323+
:return: The object that NVDA should be redirected to.
324+
"""
325+
return
326+
319327
@staticmethod
320-
def objectFromPoint(x, y):
328+
def objectFromPoint(x: int, y: int) -> "NVDAObject"):
321329
"""Retrieves an NVDAObject instance representing a control in the Operating System at the given x and y coordinates.
322-
@param x: the x coordinate.
323-
@type x: int
324-
@param y: the y coordinate.
325-
@param y: int
326-
@return: The object at the given x and y coordinates.
327-
@rtype: L{NVDAObject}
330+
:param x: the x coordinate.
331+
:param y: the y coordinate.
332+
:return: The object at the given x and y coordinates.
328333
"""
329334
kwargs = {}
330335
APIClass = NVDAObject.findBestAPIClass(kwargs, relation=(x, y))
331-
return APIClass(chooseBestAPI=False, **kwargs) if APIClass else None
336+
obj = APIClass(chooseBestAPI=False, **kwargs) if APIClass else None
337+
if not obj:
338+
return
339+
redirect = obj.objectFromPointRedirect(x, y)
340+
if redirect:
341+
obj = redirect
342+
return obj
332343

333344
@staticmethod
334345
def objectWithFocus():

user_docs/en/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Please refer to [the developer guide](https://www.nvaccess.org/files/nvda/documentation/developerGuide.html#API) for information on NVDA's API deprecation and removal process.
2222

2323
* Added a `.editorconfig` file to NVDA's repository in order for several IDEs to pick up basic NVDA code style rules by default. (#16795, @LeonarddeR)
24+
* It is now possible to redirect objects retrieved from on-screen coordinates, by using the `NVDAObject.objectFromPointRedirect` method. (#16788, @Emil-18)
2425

2526
#### Deprecations
2627

0 commit comments

Comments
 (0)