BUG in touch/mouse callbacks on Windows
Posted: Mon Jan 01, 2018 4:04 pm
When touch is RELEASED two callbacks are triggered: love.touchreleased() and love.mousereleased() and it seems to be OK,but
when touch is PRESSED only love.touchpressed() is triggered, however love.mousepressed() is triggered when touch is moved or when touch is released (together with love.mousereleased()).
Try this simple program for better understanding.
when touch is PRESSED only love.touchpressed() is triggered, however love.mousepressed() is triggered when touch is moved or when touch is released (together with love.mousereleased()).
Try this simple program for better understanding.
Code: Select all
love.window.setFullscreen(true, "desktop")
local cMP, cMR, cTP, cTR = 0, 0, 0, 0
local cMPX, cMPY = 0, 0
local cMRX, cMRY = 0, 0
local cTPX, cTPY = 0, 0
local cTRX, cTRY = 0, 0
local xMP, xMR, xTP, xTR = "", "", "", ""
function love.mousepressed(x, y, button, isTouch)
if x < 40 and y < 40 then
love.event.quit()
end
cMP = cMP + 1
xMP = "#" .. tostring(cMP) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
if isTouch then
xMP = xMP .. " (Touch)"
end
end
function love.mousereleased(x, y, button, isTouch)
cMR = cMR + 1
xMR = "#" .. tostring(cMR) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
if isTouch then
xMR = xMR .. " (Touch)"
end
end
function love.touchpressed(id, x, y, dx, dy, pressure)
if x < 40 and y < 40 then
love.event.quit()
end
cTP = cTP + 1
xTP = "#" .. tostring(cTP) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
end
function love.touchreleased(id, x, y, dx, dy, pressure)
cTR = cTR + 1
xTR = "#" .. tostring(cTR) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
end
function love.update(dt)
end
function love.draw()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle("fill", 0, 0, 40, 40)
love.graphics.setColor(0, 0, 0, 1)
love.graphics.print("QUIT", 5, 13)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.print("Last .mousepressed()", 0, 50); love.graphics.print(xMP, 160, 50)
love.graphics.print("Last .mousereleased()", 0, 70); love.graphics.print(xMR, 160, 70)
love.graphics.print("Last .touchpressed()", 0, 90); love.graphics.print(xTP, 160, 90)
love.graphics.print("Last .touchreleased()", 0, 110); love.graphics.print(xTR, 160, 110)
end