- Use callbacks instead of await

This commit is contained in:
ParticleG
2024-10-31 11:30:26 +08:00
parent 64a86b260a
commit ae37fde4b9

View File

@@ -187,11 +187,10 @@ if JS then
love.system.setClipboardText = function (str)
JS.callJS(JS.stringFunc(
[[
try {
await window.navigator.clipboard.writeText(%s);
} catch (e) {
console.warn(e);
}
window.navigator.clipboard
.writeText('')
.then(() => console.log('Copied to clipboard'))
.catch((e) => console.warn(e));
]],
str
))
@@ -201,12 +200,13 @@ if JS then
local res=""
JS.newPromiseRequest(JS.stringFunc(
[[
try {
_$_(await window.navigator.clipboard.readText());
} catch (e) {
console.warn(e);
_$_("");
}
window.navigator.clipboard
.readText()
.then(async (text) => _$_(text))
.catch((e) => {
console.warn(e);
_$_('');
});
]]
), function(data) res=data end)
return res