diff --git a/libs/simple-button.lua b/libs/simple-button.lua index f8e4ea5..8c10ab9 100644 --- a/libs/simple-button.lua +++ b/libs/simple-button.lua @@ -97,20 +97,19 @@ function button:draw() love.graphics.setColor(self.borderColor) love.graphics.rectangle('line', self.x, self.y, self.w, self.h, self.r) end ----Check if current position is hovering the button, if yes, set ``self._hovering`` to true and return true +---Check if current position is hovering the button, if it is, return true function button:isHovering(x,y) - if not y then self._hovering = false; return false end + if not y then return false end if x >= self.x and y >= self.y and x <= self.x + self.w and y <= self.y + self.h then - self._hovering = true + return true else - self._hovering = false + return false end - return self._hovering end ---Trigger press action, only when ``self._hovering`` is true ---@param isTouch? boolean Button just released by mouse?