Skip to content

Commit 90c4042

Browse files
authored
Merge c8d38c7 into 4c50375
2 parents 4c50375 + c8d38c7 commit 90c4042

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

source/NVDAObjects/__init__.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,16 @@ 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+
:type y: int
324+
:return: The object that NVDA should be redirected to.
325+
:rtype: L{NVDAObject}
326+
"""
327+
return None
328+
319329
@staticmethod
320330
def objectFromPoint(x, y):
321331
"""Retrieves an NVDAObject instance representing a control in the Operating System at the given x and y coordinates.
@@ -326,9 +336,15 @@ def objectFromPoint(x, y):
326336
@return: The object at the given x and y coordinates.
327337
@rtype: L{NVDAObject}
328338
"""
329-
kwargs = {}
330-
APIClass = NVDAObject.findBestAPIClass(kwargs, relation=(x, y))
331-
return APIClass(chooseBestAPI=False, **kwargs) if APIClass else None
339+
kwargs={}
340+
APIClass=NVDAObject.findBestAPIClass(kwargs,relation=(x,y))
341+
obj = APIClass(chooseBestAPI=False,**kwargs) if APIClass else None
342+
if not obj:
343+
return
344+
redirect = obj.objectFromPointRedirect(x,y)
345+
if redirect:
346+
obj = redirect
347+
return obj
332348

333349
@staticmethod
334350
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)