How can I add a Copy Button?

Please, Help me. I am making a Book app. I have written some Poems on different Label. I want to make a Copy Button under every Poem (Label) separately. Clicking this Button My app user can copy that poem. How can I make this Copy Button?
Thank You

1 Like

I think this is impossible in thunkable.

But I have tried something for you. Please check here.

You can definitely copy the contents of a label but where do you want those contents to be pasted/saved?

1 Like

I would also like to see a “copy to clipboard “ on click event for buttons or labels.

3 Likes

Unfortunately, I don’t think Thunkable has a copy to clipboard option. Most languages do, alas, not Thunkable.

As a bit of a hack, you COULD transfer the text from a LABEL into a TEXT_INPUT control and prompt the user to copy the text from the TEXT_INPUT.

Not a great solution, but better than nothing…

4 Likes

I want “Copy to Clipboard”

1 Like

Sorry I cannot do this way.

1 Like

Oh. Ok Thanks a lot

1 Like

I’m wondering if a JavaScript solution would work with the webviewer.



<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://thunkable.github.io/webviewer-extension/thunkableWebviewerExtension.js" type="text/javascript"></script>
  </head>
  <body>
  <script type="text/javascript">
 function copyToClipboard(value) {
  var tempInput = document.createElement("textarea");
  tempInput.value = value;
  document.body.appendChild(tempInput);
  tempInput.select();
  document.execCommand("copy");
  document.body.removeChild(tempInput);
} 

ThunkableWebviewerExtension.receiveMessage(function(message) {
copyToClipboard(message)
});
  </script>
</html>

https://x.thunkable.com/copy/00c79b0c245b1c0101476aceac42981e

this does in fact work!

the only blocks needed

@darren this would be a cool addition to sendth.at perhaps?!

8 Likes

The copy part is easy… the paste isn’t. But you haven’t said yet where the content would be pasted. Is it going into the middle of a text input field (probably difficult but not impossible)? Is it replacing a single label (easy)?

3 Likes

This is true! Within or outside of the app. Do you mean otherwise?

I’m waiting to hear back from @mikailsarkar02g0m who hasn’t specified the answer. But I meant within the app.

@jared your app is not working it is not copying

Hey there. Sorry that it’s not working, I’m not sure why. I guess you’ll have to make it yourself.

All that it takes is a webviewer, the webviewer block post message, and whatever text do you want to clip to the clipboard you send as the message from the post message block. Direct your web viewer to the following URL
Jaredgibb.github.io/CopyToClipboard

1 Like

now it works but if we set web viewer visible false it not works maybe problem with web viewer still we can se the web viewer height to 0.1 and width 0.1 and it will be invisible

try this to make it dissapear

set height to 0px
position to absolute
top offset to -50px

2 Likes

hey try
this
Screen Shot 2020-09-30 at 11.42.44 AM
probably it is a rip

well it is just with in text to copy text to clipboard then you can use @jared’s method

This example will not work for live test on the web as it is missing the ending tag:

</body>

It should be placed before the ending tag:

</html>