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

Keep hover annotation layers in sync with the mouse detector. #30829

Merged
merged 2 commits into from
Apr 11, 2019

Conversation

gspencergoog
Copy link
Contributor

Description

Adds a paint after detaching/attaching hover annotations to keep the annotation layers in sync with the annotations attached to the mouse detector.

Related Issues

Fixes #30744

Tests

Added a test that transfers focus between two listeners, and makes sure they both are detached at the end.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

@gspencergoog gspencergoog changed the title Fix hover annotation removal Keep hover annotation layers in sync with the mouse detector. Apr 10, 2019
@goderbauer goderbauer added a: desktop Running on desktop framework flutter/packages/flutter repository. See also f: labels. labels Apr 10, 2019
Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM

if (_hoverAnnotation != null && attached) {
// Attach the new annotation.
RendererBinding.instance.mouseTracker.attachAnnotation(_hoverAnnotation);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

L2560-2571 took me a while to understand, I think a clearer way is

if (newAnnotation == null && _hoverAnnotation == null)
  return
if (attached) {
  if (_hoverAnnotation != null) {
    RendererBinding.instance.mouseTracker.detachAnnotation(_hoverAnnotation);
  }
  if (newAnnotation != null) {
    RendererBinding.instance.mouseTracker.attachAnnotation(_hoverAnnotation);
  }
}
_hoverAnnotation = newAnnotation;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is clearer, except that I'd rather that _hoverAnnotation be up to date by the time attachAnnotation is called. I'll play with it some more and see if I can improve the readability.

Copy link
Contributor Author

@gspencergoog gspencergoog Apr 11, 2019

Choose a reason for hiding this comment

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

I basically reverted it to what it was before, since that was clearer. I added an assert which makes sure that something changed, since that was part of what I was trying to address with the reorg of the logic, but in reality it won't happen, since the callers all check and see that something changed before calling it.

@gspencergoog gspencergoog merged commit 8bea3fb into flutter:master Apr 11, 2019
jiisd added a commit to jiisd/flutter that referenced this pull request Apr 12, 2019
* master: (209 commits)
  Allow mouse hover to only respond to some mouse events but not all. (flutter#30886)
  Fix issue 23527: Exception: RenderViewport exceeded its maximum number of layout cycles (flutter#30809)
  Keep hover annotation layers in sync with the mouse detector. (flutter#30829)
  Use identical instead of '==' in a constant expression. (flutter#30921)
  Add toggle for debugProfileWidgetBuilds (flutter#30867)
  Revert "Manual engine roll with disabled service authentication codes (flutter#30919)" (flutter#30930)
  Manual engine roll with disabled service authentication codes (flutter#30919)
  Baseline Aligned Row (flutter#30746)
  [Material] Fix showDialog crasher caused by old contexts (flutter#30754)
  Let `sliver.dart` `_createErrorWidget` work with other Widgets (flutter#30880)
  Add more dialog doc cross-reference (flutter#30887)
  Allow downloading of desktop embedding artifacts (flutter#30648)
  CupertinoDatePicker initialDateTime accounts for minuteInterval  (flutter#30862)
  add golden tests for CupertinoDatePicker (flutter#30828)
  Simplify toImage future handling (flutter#30876)
  Fixed Table flex column layout error flutter#30437 (flutter#30470)
  Fix iTunes Transporter quirk (flutter#30883)
  Bump Android build tools to 28.0.3 in Dockerfile (flutter#30832)
  Update the upload key which seems to have trouble for some reason (flutter#30871)
  Check for invalid elevations (flutter#30215)
  ...
@gspencergoog gspencergoog deleted the fix_hover branch May 15, 2019 16:30
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: desktop Running on desktop framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mouse Tracking throwing exceptions for widgets inside a ListView that are listening for hover events
4 participants