How do I copy text to clipboard (without plugin)?

0 favourites
  • 4 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Hi! I hade a very useful javascript to copy text into clipboard but it does no longer seem to work. It just copies the whole jscript into clipboard.

    I think jscript is the only way without a plugin, right?

    Sadly I'm not good at Jscript (yet). Does someone know why it does no longer work or how to fix it? Code below (it's 1 long line):

    (it's in a function with a string as parameter for the text to copy)

    "var myTextBox=document.createElement(""input"");document.body.appendChild(myTextBox);myTextBox.setAttribute(""id"",""myTextBox_id"");document.getElementById(""myTextBox_id"").value=""" & textToCopy & """;myTextBox.select();myTextBox.setSelectionRange(0,99999);document.execCommand(""copy"");document.body.removeChild(myTextBox);"
  • Apparently that execCommand function is deprecated in browsers now, and the following is the new way. The docs indicate it won’t work in a webworker and needs the website to be https.

    Execute js "navigator.clipboard.writeText('"&Textbox.text&"')"

  • Thanks!

    I think I found a workaround for exports in worker mode. The Share plugin has a copy to clipboard button on Android. It's an extra popup (would be nice without it) but it seems to work.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Execute js "navigator.clipboard.writeText('"&Textbox.text&"')"

    That worked like a charm to me!

    I was like: #shockedChrisPrattGif

    XD

    Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)