Skip to content

Commit

Permalink
Room swapping now prevents mouse events from going through
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruor committed Feb 27, 2021
1 parent fc0c82a commit a8fa705
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/input_devices/tool_device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,46 @@ local function tryRoomSwap(x, y, button, istouch, presses)
end
end

-- Make sure we don't send release/click events for room swaps
local consumeNextRelease = false

function device.mousereleased(x, y, button, istouch, presses, click)
if consumeNextRelease then
return true
end

local currentTool = toolHandler.currentTool

if click then
local consume = tryRoomSwap(x, y, button, istouch, presses)

if consume then
consumeNextRelease = true

return true
end
end

if currentTool and currentTool.mousereleased then
print("mouse released")
currentTool.mousereleased(x, y, button, istouch, presses, click)
end
end

function device.mouseclicked(x, y, button, istouch, presses)
consumeNextRelease = false

local consume = tryRoomSwap(x, y, button, istouch, presses)
local currentTool = toolHandler.currentTool

if consume then
consumeNextRelease = true

return true
end

if currentTool and currentTool.mouseclicked then
print("mouse clicked")
currentTool.mouseclicked(x, y, button, istouch, presses)
end
end
Expand Down

0 comments on commit a8fa705

Please sign in to comment.