Reputation: 573
I have a problem detecting mouse click / touch on empty part of the stage. This is my set up:
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
stage.addEventListener('click', onStageClicked);
function onStageClicked(event) {
console.log('event.currentTarget: ', event.currentTarget);
console.log('event.target: ', event.target);
console.log('event.target.parent: ', event.target.parent);
};
I only get log in console when some shape or image that is on stage is clicked but not when actual empty part of stage is clicked. How do i detect click on empty part of the stage / canvas?
tnx
Luka
Upvotes: 0
Views: 2406
Reputation: 86
Use the 'stagemousedown' or 'stagemouseup' events. I pulled the code below from the EaselJS documentation here: http://www.createjs.com/tutorials/Mouse%20Interaction/
stage.on("stagemousedown", function(evt) {
alert("the canvas was clicked at "+evt.stageX+","+evt.stageY);
})
Upvotes: 4