Megakoresh

Parent overrides child's defaultCursor property

Recommended Posts

If I set a parent to be interactive and then add some interactive children to it, their defaultCursor property does not work.

Demonstration. Should be pretty obvious what I am trying to do, but in case it's not: I intend to allow the user to scale that green thing with those handles. The code to look at is

  let handle4 = new PIXI.Graphics().beginFill(0xFF0000, 1).drawCircle(handleRect.x+wonderfulRectangle.width, handleRect.y+wonderfulRectangle.height, 10).endFill();
  handle4.interactive = true;
  handle4.button = true;  
  handle4.hitArea = new PIXI.Circle(handle4.x, handle4.y, 10)
  handle4.defaultCursor = "nwse-resize";    
  handleRect.addChild(handle4);

handleRect is added to the wonderfulRectangle. wonderfulRectangle is interactive (can be moved around as you can see). If I set defaultCursor on the wonderfulRectangle (i.e. - parent), it works fine. But neither handleRect nor handle4 work. Is this a bug, or am I missing some undocumented steps here?

Share this post


Link to post
Share on other sites

You can also probably observe how for some reason if set any child to be interactive, you can actually grab it and move it around, and it would act as a parent, despite there being no event listeners attached to it. I can prevent this by actually adding an event listener for the same event to EVERY interactive child and then calling event.stopPropagation(), but that seems excessively counter-productive. If the child isn't listening to an event, but the parent is, the parent must receive the event, even if the child is on top.

This behaviour is highly illogical, it looks like a bug. Should I open an issue on Github?

UPDATE: I worked around the issue by creating a non-interactive PIXI.Container() and placing items in there. I then use event.target.parent's position and modify that. However that should not be necessary. If nobody replies for the next few hours with some instructions of a "proper" solution, I'll assume it's a bug and create an issue. I just don't wanna rush that, seeing as there are already friggin 200+ issues for this library on Github...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.