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