Skip to content

Commit 515b7df

Browse files
authored
Merge ffd41f2 into b47fdc5
2 parents b47fdc5 + ffd41f2 commit 515b7df

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

source/NVDAObjects/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,18 @@ 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, y):
312+
"""Redirects NVDA to another object if this object is retrieved from on screen coordinates.
313+
@param x: the x coordinate.
314+
@type x: int
315+
@param y: the y coordinate.
316+
@type y: int
317+
@return: The object that NVDA should be redirected to.
318+
@rtype: L{NVDAObject}
319+
"""
320+
return None
321+
322+
311323
@staticmethod
312324
def objectFromPoint(x,y):
313325
"""Retrieves an NVDAObject instance representing a control in the Operating System at the given x and y coordinates.
@@ -320,7 +332,12 @@ def objectFromPoint(x,y):
320332
"""
321333
kwargs={}
322334
APIClass=NVDAObject.findBestAPIClass(kwargs,relation=(x,y))
323-
return APIClass(chooseBestAPI=False,**kwargs) if APIClass else None
335+
obj = APIClass(chooseBestAPI=False,**kwargs) if APIClass else None
336+
if not obj: return
337+
redirect = obj.objectFromPointRedirect(x,y)
338+
if redirect:
339+
obj = redirect
340+
return obj
324341

325342
@staticmethod
326343
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)