This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-05-21 23:31:37 +07:00
parent 64336f7cbc
commit 7d44fc81ed

View File

@@ -112,19 +112,18 @@ function button:isHovering(x,y)
end
end
---Trigger press action, only when ``self._hovering`` is true
---@param isTouch? boolean Button just released by mouse?
function button:press(x, y, isTouch)
function button:press(x, y)
if self:isHovering(x, y) and not self._pressed then
self.codeWhenPressed()
self._pressed = true
self.codeWhenPressed()
end
end
---Trigger release action, don't need ``self._hovering`` to ``true``
---@param isTouch? boolean Button just released by mouse?
function button:release(x, y, isTouch)
function button:release(x, y)
error(self._pressed and "okay")
if self:isHovering(x, y) and self._pressed then
self.codeWhenReleased()
self._pressed = false
self.codeWhenReleased()
end
end