From 8747415461a921dd26cc2610471ddb411db0ed16 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 23 Aug 2022 11:46:04 -0700 Subject: [PATCH] allow buttons to nest as well --- button.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/button.lua b/button.lua index 748f5ae..c027b5c 100644 --- a/button.lua +++ b/button.lua @@ -1,6 +1,11 @@ -- Simple immediate-mode buttons with (currently) just an onpress1 handler for -- the left button. --- If any applicable button handler returns true, it'll propagate the click to other handlers. +-- +-- Buttons can nest in principle, though I haven't actually used that yet. +-- +-- Don't rely on the order in which handlers are run. Within any widget, all +-- applicable button handlers will run. If _any_ of them returns true, the +-- event will continue to propagate elsewhere in the widget. -- draw button and queue up event handlers function button(State, name, params) @@ -18,11 +23,15 @@ function mouse_press_consumed_by_any_button_handler(State, x, y, mouse_button) if State.button_handlers == nil then return end + local result = false for _,ev in ipairs(State.button_handlers) do if x>ev.x and xev.y and y