Add this after the other scripts in your standalone html:
Code: Select all
<script type="text/javascript">
var canvas = document.getElementById('canvas');
canvas.onpaste = function(event){
var clipboardText = event.clipboardData.getData('Text');
var myStack = document.liveCode.findStackWithName('myStandalone');
myStack.js2LC_paste(clipboardText);
};
</script>
In your LC stack you would have this as your handler:
Code: Select all
on js2lc_Paste pData
put the selectedField into tFld // returns 'field n' where n is the field number on this card.
if tFld is not empty then
put focusedObject() into tFldID // returns the long object ID of the field.
put the selectedchunk into tChunk // returns 'char n1 to n2 of field n3' where n1=startChar, n2=endChar, n3=field number on card
put (word -4 of tChunk + len(pData)) into tLoc
put the text of tFldID into tText
put pData into char (word -4 of tChunk) of tText // replaces the last char placed ('v') with paste text.
set the text of tFldID to tText
select char tLoc to tLoc -1 of tFldID
end if
end js2lc_Paste
I'll put the 'Copy' and 'Cut' scripts here too shortly.
Pi