Skip to content

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

Merged
michaelDCurran merged 2 commits into
nvaccess:masterfrom
BabbageCom:caretRect
Sep 17, 2019
Merged

displayModel.getCaretRect: return a locationHelper.RectLTRB instance#10233
michaelDCurran merged 2 commits into
nvaccess:masterfrom
BabbageCom:caretRect

Conversation

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Link to issue number:

None

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:

None

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
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Sep 17, 2019
michaelDCurran added a commit that referenced this pull request Sep 17, 2019
@LeonarddeR LeonarddeR deleted the caretRect branch September 24, 2019 05:10
@LeonarddeR LeonarddeR added the BabbageWork Pull requests filed on behalf of Babbage B.V. label Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BabbageWork Pull requests filed on behalf of Babbage B.V.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants