Jump to content

Prevent event from propagating to parent


cachopixi
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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();

        });

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...