Skip to content

Highlights - Add highlights from the controller #145

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

Closed
adrian-moisa opened this issue Sep 30, 2022 · 2 comments
Closed

Highlights - Add highlights from the controller #145

adrian-moisa opened this issue Sep 30, 2022 · 2 comments
Assignees

Comments

@adrian-moisa
Copy link
Collaborator

adrian-moisa commented Sep 30, 2022

Screen.Recording.2022-10-04.at.23.26.46.mov
@adrian-moisa adrian-moisa self-assigned this Sep 30, 2022
@adrian-moisa adrian-moisa changed the title Highlights - Improve highlights page Highlights - Add highlights from the controller. Improve the highlights page Oct 4, 2022
@adrian-moisa
Copy link
Collaborator Author

Checkout the highlights demo page for a full sample.

_controller?.addHighlight(
  HighlightM(
    textSelection: _selection.copyWith(),
    onEnter: (_) {},
    onLeave: (_) {},
    onSingleTapUp: (_) {},
  ),
);

@adrian-moisa adrian-moisa added High and removed Low labels Oct 4, 2022
@adrian-moisa
Copy link
Collaborator Author

adrian-moisa commented Oct 4, 2022

How Text Selection Works
TextGesturesService controls the selection of text after tapDown and tapUp events. Once the selection range is known it's then passed to the state store. Starting and updating the selection is triggered from the TextGestures widget and parsed by this service which in turn calls TextSelectionService. The TextGestures widget is used in the main build() method. It adds a gesture detector which interprets the various touchscreen signals into potential gestures. Once a gesture is detected in the callback executed, then the controller.updateSelection() is called which triggers the refreshEditor() which triggers a build() in main. Remember, the main build() contains the widgets generated by the documentBlocsAndLines(). These are a list of editable text lines and blocks. Once build() is triggered each EditableTextLine widget, then calls on the renderer object methods to update information. If the renderer callbacks notice that the selection is changed and within it's bounds then it triggers a paint() cycle. A new paint() cycle will "render" the selection rectangles vector data on top of the text.

I was updating the docs, I thought maybe you need this info. I was digging trough this path to figure out why the adding highlights via the controller did not work properly.

@adrian-moisa adrian-moisa changed the title Highlights - Add highlights from the controller. Improve the highlights page Highlights - Add highlights from the controller Nov 5, 2022
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

No branches or pull requests

1 participant