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

The stage click handler does not properly ignore events outside it's bounds when x,y transforms are applied #286

Closed
wants to merge 1 commit into from

Conversation

bengotow
Copy link

Consider this scenario. You have stage 1 and stage 2 side by side. Both have DisplayObjects which register for DblClick. In stage 2, you've set stage.x and stage.y so the coordinate space of the stage is shifted on top of stage 1's physical space. (I have a game where the two stages are showing different parts of the game world, side by side.) When you click on Stage 1, both stage 1 and stage 2 receive a double click event. When testing for a hit, the Stage class uses the event's X and Y, which have already had the transform applied. This causes the Stage 2 to think the hit occurred within it's bounds, even though the event's inBounds property is false, this value is never checked.

End result: The click event fires for both Stage 1 and Stage 2, even though the click was outside Stage 2.

Adding a simple check for inBounds in the hit testing functions fixed the issue. Tiny commit!

  • Ben

… description.

Consider this scenario. You have stage 1 and stage 2 side by side. Both
have DisplayObjects which register for DblClick. In stage 2, you've
transformed the stage so that it's coordinate space is shifted on top
of stage 1's physical space. When you click on Stage 1, stage 2
receives a double click event. When it's testing for a hit, it uses X
and Y, which have had the transform applied. Therefore it thinks the
hit occurred within it's bounds, even though it clearly hasn't. Adding
a simple check for inBounds fixes this.
@gskinner gskinner added the bug label Oct 23, 2014
@gskinner
Copy link
Member

Sorry for the delay on responding to this. We've made a lot of improvements to mouse handling since this was filed (though admittedly, transformed stages remain an edge case, see #477). I'm going to close this for now, but let us know if it's still a problem and we will revisit.

@gskinner gskinner closed this Oct 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants