This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-05-21 23:20:19 +07:00
parent 765ad56165
commit 43e1147968

View File

@@ -115,29 +115,15 @@ end
---Trigger press action, only when ``self._hovering`` is true
---@param isTouch? boolean Button just released by mouse?
function button:press(x, y, isTouch)
local hovering
if isTouch then
hovering = self:isHovering(x, y)
else
hovering = self._hovering
end
if hovering and not self._pressed then
self.codeWhenPressed()
if self:isHovering(x, y) and not self._pressed then
self.codeWhenReleased()
self._pressed = true
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)
local hovering
if isTouch then
hovering = self:isHovering(x, y)
else
hovering = self._hovering
end
if hovering and self._pressed then
if self:isHovering(x, y) and self._pressed then
self.codeWhenReleased()
self._pressed = false
end