html5, adding an eventlistener to a drawn image on canvas
Posted
by pfunc
on Stack Overflow
See other posts from Stack Overflow
or by pfunc
Published on 2010-04-18T23:53:57Z
Indexed on
2010/04/19
0:13 UTC
Read the original article
Hit count: 222
html5
|JavaScript
I am experimenting with html5 and I have a little image dropdown, the user selects and image and it draws it to the canvas using drawImage();
I can't seem to figure out how to add an event listener to the newly drawn image on the canvas.
I have tried putting it in a variable like so:
var newImg = ctx.drawImage(myImage, 200, 200);
and then adding an eventlistener to that, but it doesn't seem to work.
newImg.addEventListener('mousedown', onImgClick, false);
What is the correct way to do this.
© Stack Overflow or respective owner