Skip to content

Conversation

@dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Jul 15, 2019

Description

This PR introduces a few breaking changes in order to split the mouse tracking callbacks from Listener. More specifically,

  • Move onPointer{Enter,Hover,Exit} out from Listener, into a new class, MouseRegion.
  • Move onPointer{Enter,Hover,Exit}out from RenderPointerListener, into a new class, RenderMouseRegion.
  • Rename these callbacks from onPointer{Enter,Exit,Hover} into on{Enter,Exit,Hover}.

In order to keep compatibility, Listener will keep onPointer{Enter,Hover,Exit} but mark them as deprecated. They will be removed after the next stable.

For reasoning, impact, and discussion, see #36085

Regarding test change

This PR broke some tests, namely "report which user created widget caused the error" and its variant, in a weird way. It changed the widget in which an error was built, hence changing the error description from

The following assertion was thrown building
RawGestureDetector-\[LabeledGlobalKey<RawGestureDetectorState>#.+\]\(state:
RawGestureDetectorState#.+\(gestures: <none>, behavior: opaque\)\):

into

The following assertion was thrown building Listener:

which seems like a side effect of splitting RenderMouseListener out, and should be harmless.

Since these lines are not the target lines of the aforementioned tests, I decided to tell the tests to skip checking these lines. This change has been discussed with and approved by @chunhtai .

Related Issues

Tests

I added the following tests:

Replace this with a list of the tests that you added as part of this PR. A change in behaviour with no test covering it
will likely get reverted accidentally sooner or later. PRs must include tests for all changed/updated/fixed behaviors. See Test Coverage.

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?

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 15, 2019
@dkwingsmt dkwingsmt added a: desktop Running on desktop c: API break Backwards-incompatible API changes labels Jul 15, 2019
@dnfield dnfield requested a review from gspencergoog July 17, 2019 21:47
@dkwingsmt dkwingsmt requested a review from Hixie July 24, 2019 17:04
onPointerExit: (PointerExitEvent event) => _hideTooltip(),
result = MouseRegion(
onEnter: (PointerEnterEvent event) => _showTooltip(),
onExit: (PointerExitEvent event) => _hideTooltip(),
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we use methods in the previous two files and closures here? we should be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but I'm leaning towards making as few changes in other files as possible since it's a breaking PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

not sure why it being a breaking PR matters here?

But if you want to change it in another PR that's fine. :-)

if (listeners.isEmpty)
listeners.add('<none>');
properties.add(IterableProperty<String>('listeners', listeners));
// TODO(jacobr): add raw listeners to the diagnostics data.
Copy link
Contributor

Choose a reason for hiding this comment

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

@jacob314 Is there anything special we need to do to resolve this TODO?

Copy link
Contributor

Choose a reason for hiding this comment

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

properties.add(ObjectFlagProperty<PointerDownEventListener>('onPointerDown', onPointerDown, ifPresent: 'down', level: DiagnosticLevel.fine);

Would be an idiomatic way to expose each of these.
That would hide the output from the default display but let the inspector provide links to the actual listeners used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jacob314
The current way allows a clean format with the help of IterableProperty,

'listeners: down, move, up, cancel, signal'

or

'listeners: <none>'

Is there a way to maintain the current format while using ObjectFlagProperty?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not currently. Are there any cases with a subclass that wants to add an additional listener? In that case it could make sense to come up with a scheme that enables defining each listener as an ObjectFlagProperty and then aggregate the properties into a terse summary like listeners: down, move, up, cancel when generating the string output.

set onPointerEnter(PointerEnterEventListener value) {
if (_onPointerEnter != value) {
_onPointerEnter = value;
PointerEnterEventListener get onEnter => _onEnter;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's too bad we can't now name these MouseEnterEventListener, etc., but I do understand: that would make it a larger breaking change.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@dkwingsmt dkwingsmt requested a review from Hixie July 26, 2019 23:29
@dkwingsmt dkwingsmt mentioned this pull request Jul 31, 2019
9 tasks
@dkwingsmt dkwingsmt merged commit 5bb8d8f into flutter:master Aug 1, 2019
@dkwingsmt dkwingsmt deleted the split-mouse-listener branch August 1, 2019 18:07
dkwingsmt added a commit to dkwingsmt/flutter that referenced this pull request Aug 22, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: desktop Running on desktop c: API break Backwards-incompatible API changes framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants