Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

displayModel.getCaretRect: return a locationHelper.RectLTRB instance #10233

merged 2 commits into from Sep 17, 2019


Copy link

@leonardder leonardder commented Sep 17, 2019

Link to issue number:


Summary of the issue:

As part of the Python 3 migration, we removed textInfos.Rect and textInfos.Point in favor of the locationHelper classes. However, it turns out that displayModel.getCaretRect still returned a ctypes.wintypes.RECT. This function is used by the vision framework, where it has to be reconverted to a RectLTRB. It also does not benefit from other locationHelper advantages, such as point conversion and intersection calculation.

Description of how this pull request fixes the issue:

  1. displayModel.getCaretRect now returns a locationHelper.RectLTRB. This change is backwards compatible on the class level, not on the attribute level, i.e. both classes have left, top, right and bottom attributes
  2. When finding an offset for the caret, the intersection is now calculated by locationHelper instead of manually. Note that the code of the intersection method is roughly the same as the code that has been removed from the displayModel module. I also added a check that raises a RuntimeError when the caret rectangle does not overlap with the window the caret belongs to, something that will probably never happen.

Testing performed:

Tested that the caret offset can still be detected in EditableTextDisplayModelTextInfo

Known issues with pull request:


Change log entry:

  • Changes for developers, probably near the section about the removal of textInfos.* classes
    • displayModel.getCaretRect now returns an instance of locationHelper.RectLTRB.

@michaelDCurran michaelDCurran merged commit b8265c6 into nvaccess:master Sep 17, 2019
1 check passed
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Sep 17, 2019
@leonardder leonardder deleted the caretRect branch Sep 24, 2019
@leonardder leonardder added the BabbageWork label Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants