0

I am trying to create a webapp to slice a page based on a given template pic. My page has a div which i am using as the container for the stage and I want to detect when the mouse is clicked within this container so I can get the pointer position and go from there to draw the line. I tried adding an event listener to the stage like so:

stage.on(mousedown,function(){ ..... });

but this doesn't seem to work. I have been looking all over the kineticjs website and couldn't find anything to detect when the mouse is clicked within the container div. Any help is appreciated!

Thanks in advance!

2 Answers 2

1

You can listen for mouse events on the container like this:

$(stage.getContent()).on('click', function (event) {
    var pos=stage.getMousePosition();
    var mouseX=parseInt(pos.x);
    var mouseY=parseInt(pos.y);
});
Sign up to request clarification or add additional context in comments.

Comments

0

You can listen for mouse events on the container like this:
(replace toImage with your container div ID)

$('#toImage').on('mousedown', function (e) {
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.