Hello @ken,
Please find below the script. I’ve added this script on context menu showing (right click interaction). This script is adding a new item in the context menu but it is not highlighting the text. Also, using this script you will copy the entire text of the element but with some adjustments, based on your requirements, you can define specific cases.
var commands = e.originalEvent.commands;
for (i = commands.length-1; i>=0; i–)
{
commands.splice(i,1);
}
var customCommandItem = new dundas.Command(
{
id: dundas.Utility.createGuid(),
caption: ‘Copy Text’,
categoryName: ‘Copy Text’,
description: ‘CCopy Text’,
editModeOnly: false,
imageUrl:’/Content/Images/icons/contextMenu/d1.png’,
action: function()
{
var x=dataLabel4.container.textContent;
function copyToClipboard(text) {
var dummy = document.createElement(“textarea”);
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand(“copy”);
document.body.removeChild(dummy);
}
copyToClipboard(x);
e.originalEvent.commands.splice(0,e.originalEvent.commands.length);
alert(“Text copied!”);
}
});
commands.push(customCommandItem);