Skip to content

Commit d4172a9

Browse files
authored
Merge 4d37575 into 4c50375
2 parents 4c50375 + 4d37575 commit d4172a9

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

source/NVDAObjects/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,17 @@ 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+
:type x: int
323+
:param y: the y coordinate.
324+
:type y: int
325+
:return: The object that NVDA should be redirected to.
326+
:rtype: L{NVDAObject}
327+
"""
328+
return
329+
319330
@staticmethod
320331
def objectFromPoint(x, y):
321332
"""Retrieves an NVDAObject instance representing a control in the Operating System at the given x and y coordinates.
@@ -326,9 +337,15 @@ def objectFromPoint(x, y):
326337
@return: The object at the given x and y coordinates.
327338
@rtype: L{NVDAObject}
328339
"""
329-
kwargs = {}
340+
kwargs={}
330341
APIClass = NVDAObject.findBestAPIClass(kwargs, relation=(x, y))
331-
return APIClass(chooseBestAPI=False, **kwargs) if APIClass else None
342+
obj = APIClass(chooseBestAPI=False, **kwargs) if APIClass else None
343+
if not obj:
344+
return
345+
redirect = obj.objectFromPointRedirect(x, y)
346+
if redirect:
347+
obj = redirect
348+
return obj
332349

333350
@staticmethod
334351
def objectWithFocus():

user_docs/en/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ 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)
112113
* NVDA will log its executable architecture (x86) at startup. (#16432, @josephsl)
113114
* `wx.CallAfter`, which is wrapped in `monkeyPatches/wxMonkeyPatches.py`, now includes proper `functools.wraps` indication. (#16520, @XLTechie)
114115
* There is a new module for scheduling tasks `utils.schedule`, using the pip module `schedule`. (#16636)

0 commit comments

Comments
 (0)