Hi I’m trying to create a library that extends p5. I want to add event handlers to the sketch. I tried to use _onmousedown event present in p5 prototype, but its giving me an errror. How can I achieve this?
I could just attach an event listener to document. But is there a more elegant way of doing this?
It seems indeed if we call method p5::mousePressed() multiple times it would replace its previous callback w/ the current 1.
If you need a p5.Element to have multiple callbacks for the same event you’re gonna need to call method EventTarget::addEventListener() over its property p5.Element::elt: