about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--button.lua2
-rw-r--r--edit.lua6
2 files changed, 6 insertions, 2 deletions
diff --git a/button.lua b/button.lua
index 5042ae6..66a2c00 100644
--- a/button.lua
+++ b/button.lua
@@ -15,7 +15,7 @@ function propagate_to_button_handlers(x, y, mouse_button)
   for _,ev in ipairs(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
-        ev.onpress1()
+        return ev.onpress1()
       end
     end
   end
diff --git a/edit.lua b/edit.lua
index 9a7674d..5bc8bad 100644
--- a/edit.lua
+++ b/edit.lua
@@ -162,6 +162,7 @@ function edit.draw(State)
                        end
                        schedule_save(State)
                        record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)})
+                       return true  -- don't handle any other events with this mouse button press
                      end,
         })
       end
@@ -207,7 +208,10 @@ end
 function edit.mouse_pressed(State, x,y, mouse_button)
   if State.search_term then return end
 --?   print('press', State.selection1.line, State.selection1.pos)
-  propagate_to_button_handlers(x,y, mouse_button)
+  if propagate_to_button_handlers(x,y, mouse_button) then
+    -- press on a button and it returned 'true' to short-circuit
+    return
+  end
 
   for line_index,line in ipairs(State.lines) do
     if line.mode == 'text' then