Clipboard Paste into Textarea

Hi
Have tried various options on https://wiki.nsbasic.com/ClipboardData
but can’t find a way of pasting from the clipboard into a textarea I want to use a button to pull the text in).
I found the

TextArea2.select(); document.execCommand(“Copy”);

code worked well for copying to the clipboard, but nothing seemed to work when trying to paste into the textarea.
Any ideas, please?
Thanks.

There’s a Clipboard sample. Did you try that?

Yes, thanks. What I was after was - eg - copying some text in Notepad and pasting into a TextArea control.

Sorry, should have added - I want to paste into the TextArea without pressing Ctrl+V and by pressing a button within the app.

Hmmm… The Clipboard sample seems to handle that. Is it not working for you?

Thanks.

Looking at the button in the sample seems to just select the Input1 control and then copy to the clipboard. Pasting doesn’t seem to be catered for…?

I have read that pasting is not allowed, for security reasons. One reply on javascript execCommand("paste") not working - Stack Overflow
is “For security reason it is blocked in chrome. Even office 365 ask to their users to use shorcuts ctrl+v instead of copy.”

From https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand:

paste
Pastes the clipboard contents at the insertion point (replaces current selection). Disabled for web content. See [1].”

Is there a way of forcing enablement for web content? Or working around the above, please?

Maybe I’ve missed something :frowning:

You’re right - when I tested it, I did ctrl-V, not the Paste button.

Furthermore, I can see the potential for malice if this were to be allowed.

Makes sense - thanks for your advice :slight_smile:

It occured to me that the same restriction might not exist for native apps. Here are some plugins which may help:

Thanks. Will have a look at this :slight_smile: