Skip to content

Commit 62efd5a

Browse files
authored
Merge fcd57fa into b47fdc5
2 parents b47fdc5 + fcd57fa commit 62efd5a

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

source/NVDAObjects/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ def findOverlayClasses(self, clsList: typing.List[typing.Type["NVDAObject"]]) ->
308308

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

311+
def objectFromPointRedirect(self, x: int, y: int) -> NVDAObject | None:
312+
"""Redirects NVDA to another object if this object is retrieved from on screen coordinates.
313+
:param x: the x coordinate.
314+
@param y: the y coordinate.
315+
@type y: int
316+
@return: The object that NVDA should be redirected to.
317+
@rtype: L{NVDAObject}
318+
"""
319+
return None
320+
311321
@staticmethod
312322
def objectFromPoint(x,y):
313323
"""Retrieves an NVDAObject instance representing a control in the Operating System at the given x and y coordinates.
@@ -320,7 +330,13 @@ def objectFromPoint(x,y):
320330
"""
321331
kwargs={}
322332
APIClass=NVDAObject.findBestAPIClass(kwargs,relation=(x,y))
323-
return APIClass(chooseBestAPI=False,**kwargs) if APIClass else None
333+
obj = APIClass(chooseBestAPI=False,**kwargs) if APIClass else None
334+
if not obj:
335+
return
336+
redirect = obj.objectFromPointRedirect(x,y)
337+
if redirect:
338+
obj = redirect
339+
return obj
324340

325341
@staticmethod
326342
def objectWithFocus():

user_docs/en/changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ It is especially useful to read the error location markers in tracebacks. (#1632
109109
* Table metadata can be added to an optional `brailleTables` section in the add-on manifest or to a `.ini` file with the same format found in the brailleTables subdirectory of the scratchpad directory.
110110
* Please consult the [braille translation tables section in the developer guide](https://www.nvaccess.org/files/nvda/documentation/developerGuide.html#BrailleTables) for more details.
111111
* When a `gainFocus` event is queued with an object that has a valid `focusRedirect` property, the object pointed to by the `focusRedirect` property is now held by `eventHandler.lastQueuedFocusObject`, rather than the originally queued object. (#15843)
112+
* It is now possible to redirect objects retrieved from on screen coordinates, by using the NVDAObject.objectFromPointRedirect method. (#16788, @Emil-18)
113+
*
112114
* NVDA will log its executable architecture (x86) at startup. (#16432, @josephsl)
113115
* `wx.CallAfter`, which is wrapped in `monkeyPatches/wxMonkeyPatches.py`, now includes proper `functools.wraps` indication. (#16520, @XLTechie)
114116
* There is a new module for scheduling tasks `utils.schedule`, using the pip module `schedule`. (#16636)

0 commit comments

Comments
 (0)