dont activate button, if disabled

This commit is contained in:
Insality 2019-03-30 17:16:51 +03:00
parent a56c691e86
commit c80ea35060
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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