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

Don't transform to local coordinates when mouse input is already captured #42

Open
tlvenn opened this issue Feb 25, 2022 · 3 comments
Open

Comments

@tlvenn
Copy link
Contributor

tlvenn commented Feb 25, 2022

While i was debugging an issue with mouse input, I noticed that globalToLocal(input.stagePosition, input.localPosition); is always called even though it is only needed for the hitTouch which is only happening when the input has not been captured already.

https://github.com/roipeker/graphx/blob/master/lib/src/display/display_object.dart#L113

We should avoid this op in that case given this op will be called for each sprite / shape in your entire scene.

@tlvenn
Copy link
Contributor Author

tlvenn commented Feb 25, 2022

Also it seems we keep iterating the whole scene even when the input is captured in order to match $mouseOverObj but if $mouseOverObj is null shouldn't we stop iterating once the input is captured ?

@roipeker
Copy link
Owner

I think the original implementation is meant to propagate events. Even if bubbling system isn't existent the child objects should be able to process the signal. You should be able to read touch events "globally" on the stage. The propagation shouldn't end, because dev needs to be able to capture pointer events in many display objects hierarchies. Maybe my idea isn't accurate. But i think i faced that dilemma while developing the input capture part.

@tlvenn
Copy link
Contributor Author

tlvenn commented Feb 25, 2022

The propagation is happening in dispatchMouseCallback

https://github.com/roipeker/graphx/blob/master/lib/src/display/display_object.dart#L190

Nothing more is being dispatched at all from that whole recursive iteration loop apart from the mouseover logic bit.

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

2 participants