Posted 30 March 2020, 3:42 pm EST
Hi all,
I’ve read very carefully the Clipboard class documentation
https://www.grapecity.com/wijmo/api/classes/wijmo.clipboard.html
so I got aware that the Copy method works only after user press a clipboard copy command (such as ctrl+c).
My goal is to create an external “Copy to clipboard” button, so on the click I’ve
- set the active element from the button to one cell of the selection (like if the user has pressed ctrl+c on it)
- dispatched a synthetic event for the ctrl+c (programmatically)
Now let’s refer to this part of the code (wijmo.js)
e._copyPaste = function (e, n)
{
for (var r = t.getActiveElement(), i = t.closest(r, ".wj-control"); i && t.Control.getControl(i); )
{
debugger;
i = i.parentElement;
}
debugger;
if (i = i || document.body)
{
var o = t.createElement('<textarea class="wj-clipboard" style="position:fixed;opacity:0"/>', i);
t.isString(e) && (o.value = e), o.select(), o.onkeydown = function (t)
{
t.preventDefault()
}, setTimeout(function ()
{
r.focus(), t.removeChild(o), t.isFunction(n) && n(o.value)
}, t.Control._CLIPBOARD_DELAY)
}
}
Variables and behavior seem the same by comparing “crtl+c” and “synthetic ctrl+c” events but the content is still not copied to the clipboard in this second case. Any help?
Thank you in advance,
Luca.