- Joined
- Jul 17, 2017
- Messages
- 77
I'm experimenting with adding the newish Clipboad API to the existing GetClipboard function so it'll be available on HTML5.
This is what I have so far, in gametarget.js:
Problem is that it uses an asynchronous promise to get the data, so this will always return "promise pending..." to Cerberus and the actual clipboard data gets lost to the void, even if the permissions have been set. Does anyone know how to get async js code to talk nicely to CX?
This is what I have so far, in gametarget.js:
Code:
BBGame.prototype.GetClipboard=function(){
console.log("Attempting to read clipboard...")
if (!navigator.clipboard.readText) {
console.log( "navigator.clipboard.readText is not supported by this browser.");
return "";
}
navigator.clipboard.readText().then(
clipText => {
console.log("CLIP TEXT : '",clipText,"'");
return clipText;
}
)
return "promise pending...";
}
Problem is that it uses an asynchronous promise to get the data, so this will always return "promise pending..." to Cerberus and the actual clipboard data gets lost to the void, even if the permissions have been set. Does anyone know how to get async js code to talk nicely to CX?