about summary refs log tree commit diff stats
path: root/button.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-08-24 13:40:36 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-08-24 13:40:36 -0700
commit9c72ff1bb4fc1ba08acfb0324079da6fe49f3a4a (patch)
tree3e12136eaf70046f0700e92e546065d08578b9fa /button.lua
parentce31b74b10798799f03b1a9fb54dff491a1cf223 (diff)
downloadtext.love-9c72ff1bb4fc1ba08acfb0324079da6fe49f3a4a.tar.gz
bugfix: propagate mouse press if any button would
Before this commit I was propagating press events only if _all_ buttons
would.
Diffstat (limited to 'button.lua')
-rw-r--r--button.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/button.lua b/button.lua
index d8ab601..7549169 100644
--- a/button.lua
+++ b/button.lua
@@ -23,15 +23,17 @@ function mouse_press_consumed_by_any_button_handler(State, x, y, mouse_button)
   if State.button_handlers == nil then
     return
   end
-  local result = false
+  local button_pressed = false
+  local consume_press = true
   for _,ev in ipairs(State.button_handlers) do
     if x>ev.x and x<ev.x+ev.w and y>ev.y and y<ev.y+ev.h then
       if ev.onpress1 and mouse_button == 1 then
-        if not ev.onpress1() then
-          result = true
+        button_pressed = true
+        if ev.onpress1() then
+          consume_press = false
         end
       end
     end
   end
-  return result
+  return button_pressed and consume_press
 end