Copy link to clipboard
Copied
Hello all,
I am using Captivate 10. I am wanting to do one of any of the following:
1. Press a button to copy a variables value from captivate to the clipboard
2. Press a button copy a SmartShape's text to the clipboard
It doesn't matter which one it comes from, just so long as I can get the desired text into the clipboard. This is something I've been trying to work out on my own to no avail. If someone could point me in the right direction or give me some advice on how I might go about doing this, I would greatly appreciate it!
1 Correct answer
If using HTML5, can try something like this:
var myValue = window.cpAPIInterface.getVariableValue("tempX");
function copyVal(val)
{
var inpt = document.createElement('input'); // create an input element
document.body.appendChild(inpt); //append it to the dom
inpt.value = val; // set its value based on passed parameter
inpt.select(); // select
document.execCommand('copy',false); // execute copy cmd
inpt.remove(); // remove element
}
copyVal(myValue); // call function and pass
...Copy link to clipboard
Copied
If using HTML5, can try something like this:
var myValue = window.cpAPIInterface.getVariableValue("tempX");
function copyVal(val)
{
var inpt = document.createElement('input'); // create an input element
document.body.appendChild(inpt); //append it to the dom
inpt.value = val; // set its value based on passed parameter
inpt.select(); // select
document.execCommand('copy',false); // execute copy cmd
inpt.remove(); // remove element
}
copyVal(myValue); // call function and pass your var value
There is no error checking here, which may present a usability issue. You would need to test this cross-broswer/platform/mobile. I have no idea about security issues with this approach.
Copy link to clipboard
Copied
Awesome! I really appreciate it. This for sure gave me exactly what I was looking for. Thank you so much!
Copy link to clipboard
Copied
Glad it worked out for you.

