diff --git a/libs/simple-button.lua b/libs/simple-button.lua index 387080a..c442da6 100644 --- a/libs/simple-button.lua +++ b/libs/simple-button.lua @@ -117,17 +117,13 @@ end ---Trigger release action, don't need ``self._hovering`` to ``true`` ---@param isMouse? boolean Button just released by mouse? function button:release(x, y, isMouse) - if self:isHovering(x, y) then - if self._pressed then - self.codeWhenReleased() - self._pressed = false - if isMouse then - self._hovering = self:isHovering(x, y) - error("mouse") - else - self._hovering = false - error("touch") - end + if self:isHovering(x, y) and self._pressed then + self.codeWhenReleased() + self._pressed = false + if isMouse then + self._hovering = self:isHovering(x, y) + else + self._hovering = false end end end diff --git a/main.lua b/main.lua index 94cbb67..6ca9bd9 100644 --- a/main.lua +++ b/main.lua @@ -120,10 +120,12 @@ function love.draw() end function love.mousepressed(x, y, b, isTouch, presses) + if isTouch then return end local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y) SCENE:onInputPress{type = "mouse", x = x, y = y, button = b, presses = presses} end function love.mousereleased(x, y, b, isTouch, presses) + if isTouch then return end local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y) SCENE:onInputRelease{type = "mouse", x = x, y = y, button = b, presses = presses} end