Skip to content

Added a method on the NVDAObject class called objectFromPointRedirect#16807

Merged
seanbudd merged 16 commits into
nvaccess:masterfrom
Emil-18:objectFromPointRedirect
Jul 14, 2024
Merged

Added a method on the NVDAObject class called objectFromPointRedirect#16807
seanbudd merged 16 commits into
nvaccess:masterfrom
Emil-18:objectFromPointRedirect

Conversation

@Emil-18

@Emil-18 Emil-18 commented Jul 3, 2024

Copy link
Copy Markdown
Contributor

Link to issue number:

fixes #16788

Summary of the issue:

It is impossible to redirect what object NVDA retrieves from on screen coordinates. This makes it dificult to implement mouse and touch support for objects that has a location that differs from the location provided by the API class.

Description of user facing changes

None

Description of development approach

A new method called objectFromPointRedirect has been added to the NVDAObject class. This method is called from objectFromPoint, and given the x and y parameters. If it returns an NVDAObject, that object will be returned by objectFromPoint

Testing strategy:

Tested by always returning the desktop object. It worked as it should.

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Added a method to redirect NVDA to another object based on screen coordinates.
  • Improvements

    • Logging enhanced to include executable architecture at startup.
    • Improved task scheduling with a new module utilizing the schedule pip module.

@Emil-18 Emil-18 changed the title Added a method on the NVDAObject class called objectFrommPointRedirect Added a method on the NVDAObject class called objectFromPointRedirect Jul 3, 2024
@Adriani90

Copy link
Copy Markdown
Collaborator

This gives a good base for developing improvements to mouse tracking and probably also for indent navigation. cc: @mltony

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 515b7df2a7

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 78ac29a93a

Comment thread source/NVDAObjects/__init__.py Outdated
Comment thread source/NVDAObjects/__init__.py Outdated
Comment thread source/NVDAObjects/__init__.py Outdated
Emil-18 and others added 3 commits July 3, 2024 16:40
Co-authored-by: Leonard de Ruijter <3049216+LeonarddeR@users.noreply.github.com>
Co-authored-by: Leonard de Ruijter <3049216+LeonarddeR@users.noreply.github.com>
Co-authored-by: Leonard de Ruijter <3049216+LeonarddeR@users.noreply.github.com>
@AppVeyorBot

Copy link
Copy Markdown
  • PASS: Translation comments check.
  • PASS: License check.
  • FAIL: Unit tests. See test results for more information.
  • FAIL: Lint check. See test results and lint artifacts for more information.
  • FAIL: System tests (tags: installer NVDA). See test results for more information.
  • Build (for testing PR): https://ci.appveyor.com/api/buildjobs/8o1el1qt1pucwolx/artifacts/output/nvda_snapshot_pr16807-32755,62efd5a3.exe
  • CI timing (mins):
    INIT 0.0,
    INSTALL_START 1.1,
    INSTALL_END 1.1,
    BUILD_START 0.0,
    BUILD_END 12.9,
    TESTSETUP_START 0.0,
    TESTSETUP_END 0.2,
    TEST_START 0.0,
    TEST_END 0.6,
    FINISH_END 0.2

See test results for failed build of commit 62efd5a3d0

@Emil-18

Emil-18 commented Jul 4, 2024

Copy link
Copy Markdown
Contributor Author

@LeonarddeR the line def objectFromPointRedirect(self, x: int, y: int) -> NVDAObject | None: gave an error since NVDAObject is not defined yet. Should I enclose the entire type hint in a string?

@LeonarddeR

Copy link
Copy Markdown
Collaborator

you should indeed store "NVDAObject" in a String probably.

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 90c40420a6

@Emil-18

Emil-18 commented Jul 4, 2024

Copy link
Copy Markdown
Contributor Author

@LeonarddeR Ok. Do you know how I can check what causes the linting issues, as the flake8.txt file is no longer present?

@hwf1324

hwf1324 commented Jul 4, 2024

Copy link
Copy Markdown
Contributor

@LeonarddeR Ok. Do you know how I can check what causes the linting issues, as the flake8.txt file is no longer present?

I am also experiencing this issue, strangely enough the ruff extension of my vs code is not reporting the appropriate error. Maybe formatting is not considered an error.

You can run runlint.bat

Here is the output from the CI above

appveyor\scripts\tests\lintCheck.ps1
Ensuring NVDA Python virtual environment
Warning: Running in non-interactive mode. Defaults are assumed for prompts, if applicable
call ruff check --fix --output-file=C:\projects\nvda\testOutput\lint\/PR-lint.xml --output-format=junit
Deactivating NVDA Python virtual environment
Ensuring NVDA Python virtual environment
Warning: Running in non-interactive mode. Defaults are assumed for prompts, if applicable
call ruff format --diff
--- source\NVDAObjects\__init__.py
+++ source\NVDAObjects\__init__.py
@@ -336,12 +336,12 @@
 		@return: The object at the given x and y coordinates.
 		@rtype: L{NVDAObject}
 		"""
-		kwargs={}
-		APIClass=NVDAObject.findBestAPIClass(kwargs,relation=(x,y))
-		obj = APIClass(chooseBestAPI=False,**kwargs) if APIClass else None
+		kwargs = {}
+		APIClass = NVDAObject.findBestAPIClass(kwargs, relation=(x, y))
+		obj = APIClass(chooseBestAPI=False, **kwargs) if APIClass else None
 		if not obj:
 			return
-		redirect = obj.objectFromPointRedirect(x,y)
+		redirect = obj.objectFromPointRedirect(x, y)
 		if redirect:
 			obj = redirect
 		return obj

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 9aafa0633e

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit d4172a993a

@Emil-18 Emil-18 marked this pull request as ready for review July 11, 2024 23:02
@Emil-18 Emil-18 requested a review from a team as a code owner July 11, 2024 23:02
@Emil-18 Emil-18 requested a review from michaelDCurran July 11, 2024 23:02
@coderabbitai

coderabbitai Bot commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent changes introduce a method called objectFromPointRedirect in the NVDAObject class. This method allows NVDA to redirect to another object based on screen coordinates before returning the object from objectFromPoint. Additional enhancements include improved logging of executable architecture at startup and task scheduling improvements using the schedule plugin module.

Changes

Files Change Summary
source/NVDAObjects/__init__.py Added objectFromPointRedirect method for object redirection based on screen coordinates. Updated objectFromPoint to use this method.
user_docs/en/changes.md Documented new objectFromPointRedirect, logging improvements, wx.CallAfter enhancement, and new task scheduling module.
monkeyPatches/wxMonkeyPatches.py Enhanced wx.CallAfter with functools.wraps indication.
utils/schedule Introduced a new module for task scheduling using the schedule pip module.

Sequence Diagram(s)

Object Redirection Flow

sequenceDiagram
    participant User
    participant NVDAObject
    participant NVDAObjects__init__
    User ->> NVDAObject: objectFromPoint(x, y)
    NVDAObject ->> NVDAObjects__init__: objectFromPointRedirect(x, y)
    alt Redirect Found
        NVDAObjects__init__ ->> User: Return redirected object
    else No Redirect
        NVDAObject ->> User: Return original object
    end
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Add objectFromPointRedirect method on the NVDAObject class (#16788)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
user_docs/en/changes.md (2)

112-112: Ensure each change log entry follows the style guide.

The entry should follow the style guide of one sentence per line.

- * It is now possible to redirect objects retrieved from on screen coordinates, by using the NVDAObject.objectFromPointRedirect method. (#16788, @Emil-18)
+ * It is now possible to redirect objects retrieved from on screen coordinates.
+ * This can be done by using the NVDAObject.objectFromPointRedirect method. (#16788, @Emil-18)

115-115: Add GitHub user reference.

The entry should reference the GitHub user who contributed the change.

- * There is a new module for scheduling tasks `utils.schedule`, using the pip module `schedule`. (#16636)
+ * There is a new module for scheduling tasks `utils.schedule`, using the pip module `schedule`. (#16636, @contributor)

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Emil-18

Comment thread source/NVDAObjects/__init__.py Outdated
@@ -328,7 +339,13 @@ def objectFromPoint(x, y):
"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you've rewritten this function, could you update this function header to:

  • move the type hints from the docstring into the function header
  • update the docstring to use sphinx syntax

Comment thread user_docs/en/changes.md Outdated
@seanbudd seanbudd marked this pull request as draft July 12, 2024 00:27
Emil-18 and others added 4 commits July 12, 2024 12:27
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 4e4c4f5b8e

@Emil-18 Emil-18 marked this pull request as ready for review July 12, 2024 14:09
@seanbudd seanbudd merged commit 9b63cd5 into nvaccess:master Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a getObjectFromPointRedirect method on the NVDAObject class

6 participants