Fix 2 buttons can be highlighted at the same time in simple-button module

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-05-24 22:41:22 +07:00
parent b14fe9c86c
commit e809490043

View File

@@ -265,7 +265,16 @@ end
---@param x number # Mouse position
---@param y number # Mouse position
function BUTTON.checkHovering(list, x, y)
for _, v in pairs(list) do v._hovering = v:isHovering(x, y) end
local highlighted_a_button = false
for _, v in pairs(list) do
if highlighted_a_button then
v._hovering = false
else
v._hovering = v:isHovering(x, y)
end
if not highlighted_a_button and v._hovering then highlighted_a_button = true end
end
end
--- Trigger the press action, only if ``button._hovering == true``