javascript - Events in elements within a canvas -
i've draw image inside canvas tag. how add events it? want when user clicks in image.
character.addeventlistener('click', function() { alert('foo'); }, true); /* character var (image object) within canvas */
thank you.
there's no way add event handlers actual drawings on canvas. can handle events entire canvas - that's it.
your options @ point either add abstraction on canvas, , lookup drawings have there based on coordinates canvas click events - or drop canvas altogether , go e.g. svg. raphaƫl library (http://raphaeljs.com/) can latter.
Comments
Post a Comment