KineticJS icon indicating copy to clipboard operation
KineticJS copied to clipboard

Click goes throught layer after Kinetic.Node.create()

Open Corandy opened this issue 13 years ago • 1 comments

I'm importing a JSON layer to the stage.

var loadedobject = Kinetic.Node.create(data); maplayer.add(loadedobject);

Code to change the content what I'm importing seems to do like fine: (BTW: .maplayer2 is the layer I have imported)

maplayer.get('.maplayer2')[0].setScale(browserwidthdifference); maplayer.get('.maplayer2')[0].setY(browserheight/2); maplayer.setDraggable(true);

However if do the code below it doesn't work:

maplayer.on('click', function() { console.log('help');
});

maplayer.get('.maplayer2')[0].on('click', function() { console.log('help');
});

I have let the background black of the imported layer so I can see the detection. However if I do:

backgroundlayer.on('click', function() { console.log('help');
});

I get the click responses even if I click on the imported layer which is clearly on top of the other layer. maplayer.moveToTop() doens't work either. All alternations work but the click events won't work with the imported object.

If I create another object in maplayer it will response to it when I click on it, but the imported layer in the layer will still be not detected.

error

Corandy avatar May 01 '13 07:05 Corandy

Everything worked when you save the objects within a group object instead of a layer

Corandy avatar May 01 '13 08:05 Corandy