cachopixi Posted April 20, 2019 Share Posted April 20, 2019 If I have a container and a child of it, and both have "interactable" set to true. I noticed that if I click on the child, both the child and its container get the event. How can I prevent the event from propagating to the parent? Ie. imagine the container is the play area, and on top of it there's objects. If I click the play area I expect the character to move there. If I click an object, I expect to interact with it, and stop the propagation there, so it doesn't get to the play area callback. Thanks! Quote Link to comment Share on other sites More sharing options...
jonforum Posted April 20, 2019 Share Posted April 20, 2019 hum make a flag in parent and when the child event are call , check if the parent event flag are true ? Maybe there is other solution, but I proceed in this way in complex situations.:) Link your objet with reference. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 20, 2019 Share Posted April 20, 2019 https://github.com/pixijs/pixi.js/blob/dev/packages/interaction/src/InteractionEvent.js#L52 jonforum 1 Quote Link to comment Share on other sites More sharing options...
cachopixi Posted April 22, 2019 Author Share Posted April 22, 2019 Thanks! I'm using Typescript, and the default callback parameter was of type DisplayObject so I was not finding stopPropagation(). Ie. : mySprite.on('click', function (ev) { }); Forcing an InteractionEvent type worked mySprite.on('click', function (ev: PIXI.interaction.InteractionEvent) { ev.stopPropagation(); }); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 22, 2019 Share Posted April 22, 2019 v4 or v5 typescript? Quote Link to comment Share on other sites More sharing options...
cachopixi Posted April 28, 2019 Author Share Posted April 28, 2019 pixijs 4.8.7 typings file was for 4.8. After updating it the problem went away my bad! thanks for the help btw, new typings file says 4.8 just like the old one Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 28, 2019 Share Posted April 28, 2019 It doesn't matter because we are rolling out v5 with new automatically build typings, but you can create an issue at https://github.com/pixijs/pixi-typescript Quote Link to comment Share on other sites More sharing options...
cachopixi Posted April 28, 2019 Author Share Posted April 28, 2019 > automatically build typings that sounds amazing! thanks for all the great work! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 28, 2019 Share Posted April 28, 2019 Just now, cachopixi said: > automatically build typings that sounds amazing! thanks for all the great work! Well, they are generated from docs, and people already report problems that we fix. Its good that we have super-official support now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.