I would like to add a “paste” event listener to a p5.Graphic, how can I do that ?
I’ve tried like this:
g = createGraphics(100, 100); g.elt.addEventListener("paste", pasteEvent => console.log("paste"));
But the event is not firing when I try to paste something inside g. I have other event listeners for g, such as drop, mouseover etc, all working, it’s just this paste event that doesn’t work, I don’t understand why. If I remove “g.elt.” or replace with “g.elt.parentElement” then the event works but on the entire window, I would like to be able to paste only inside g.
I also tried to add
My actual workaround is to set a variable “mouseInside” to true in g’s mouseover event , set it to false in g’s mouseout event, and then in the window’s paste event I check if this variable is true, it works…
Is there a better solution ?