[SOLVED] How to paste into the browser more than once


#1

I’ve just set up a scene to accept text that has been pasted in. This works fine once, but I’d like to get it working for multiple paste events.

Here’s a link to a public project…

https://playcanvas.com/project/612985/overview/paste-twice-issue

Also, here’s the ideal way to test it - Play the link, open up the console ( F12 ), copy some text, then Control+V paste it over the 3D window ( possibly after clicking on the window first ).

The above should work great.

Now, try to paste the text in again ( try copying and pasting new text etc ) - this doesn’t seem to work, after the first paste.

It’s very strange that it just works once!


#2

You’re not passing the correct parameters to addEventListener. Check out the API reference for that function:

Deleting the third parameter (this) makes your code work.


#3

Cheers for the info @will!

I ended up using the other method that was in the project but I’ll change it now to use addEventListener correctly.

I updated the example to show the correct method ( keeping the incorrect one for reference ).