This commit is contained in:
ParticleG
2024-11-02 18:32:39 +08:00
parent eb7e20d157
commit 57d42a84a4

View File

@@ -5,6 +5,7 @@ local trigCHN=love.thread.getChannel('CLIP_trig')
JS=require'Zframework.js' JS=require'Zframework.js'
love.timer=require'love.timer' love.timer=require'love.timer'
local retrieving=false
while true do while true do
if trigCHN:getCount()>0 then if trigCHN:getCount()>0 then
trigCHN:pop() trigCHN:pop()
@@ -22,6 +23,7 @@ while true do
)) ))
end end
-- Get Clipboard -- Get Clipboard
if not retrieving then
JS.newPromiseRequest( JS.newPromiseRequest(
JS.stringFunc[[ JS.stringFunc[[
window.navigator.clipboard window.navigator.clipboard
@@ -33,11 +35,14 @@ while true do
while getCHN:getCount()>0 do print('getCHN count:', getCHN:getCount()); getCHN:pop() end while getCHN:getCount()>0 do print('getCHN count:', getCHN:getCount()); getCHN:pop() end
print('Clipboard:', data) print('Clipboard:', data)
getCHN:push(data) getCHN:push(data)
retrieving=false
end, end,
function(id,error) print(id, error) end, function(id,error) print(id, error) end,
2, 2,
'getClipboardText' 'getClipboardText'
) )
retrieving=true
end
end end
JS.retrieveData(.0626) JS.retrieveData(.0626)
love.timer.sleep(.0626) love.timer.sleep(.0626)