From e8094900438b823e393a11c7d265014520016a23 Mon Sep 17 00:00:00 2001 From: "Squishy (C6H12O6+NaCl+H2O)" <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri, 24 May 2024 22:41:22 +0700 Subject: [PATCH] Fix 2 buttons can be highlighted at the same time in simple-button module --- libs/simple-button.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/simple-button.lua b/libs/simple-button.lua index 154f1a0..94b4b37 100644 --- a/libs/simple-button.lua +++ b/libs/simple-button.lua @@ -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``