diff --git a/druid/base/button.lua b/druid/base/button.lua index 38a6fa2..001f1a1 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -64,6 +64,10 @@ end -- @param action_id - input action id -- @param action - input action function M.on_input(instance, action_id, action) + if not helper.is_enabled(instance.node) then + return false + end + if gui.pick_node(instance.node, action.x, action.y) then if action.pressed then -- Can interact if start touch on the button diff --git a/druid/helper/helper.lua b/druid/helper/helper.lua index fe150da..a23f5c9 100644 --- a/druid/helper/helper.lua +++ b/druid/helper/helper.lua @@ -36,4 +36,15 @@ function M.step(current, target, step) end +function M.is_enabled(node) + local is_enabled = gui.is_enabled(node) + local parent = gui.get_parent(node) + while parent and is_enabled do + is_enabled = is_enabled and gui.is_enabled(parent) + parent = gui.get_parent(parent) + end + return is_enabled +end + + return M \ No newline at end of file