The VCL/FMX way of copying text to the clipboard doesn't work in TMS Web Core.
How can I copy text (Strings) to the clipboard in a Delphi TMS Web Core Website?
Add a TWebClipboard
component to your form and then you can copy text to it by running:
WebClipboard.CopyToClipboard('Your String to Copy to Clipboard');
You can make your own procedure that creates and uses the TWebClipboard
component from the WEBLib.Clipboard
unit:
procedure CopyTextToClipboard(aText: String);
var
WebClipboard: TWebClipboard;
begin
WebClipboard := TWebClipboard.Create(self);
try
WebClipboard.CopyToClipboard(aText);
finally
WebClipboard.Free;
end;
end;
You can make a Delphi function that uses JavaScript to copy text to the clipboard:
procedure CopyTextToClipboard(aText: String);
begin
asm
window.navigator.clipboard.writeText(aText);
end;
end;