When I disable the gui node with gui.set_enabled false, it is still available for pick_node in Input.
Is this the excepted behavior?
In my case it is a box node as button. Node is not rendered but it is clickable:
function init(self)
...
gui.set_enabled(my_button, false)
...
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
if gui.pick_node(my_button, action.x, action.y) then
print("click")
end
end
end
It’s by design, but I can agree that it might be confusing before you know that is how it works. For nested view hierarchies it’s worth pointing out that you may wish to check if a parent is disabled as well:
I ran into the same frustrating problem causing bugs with disabled GUI’s because I assumed disabling them would mean they are not pickable because they’re disabled. Easily solved by adding “gui.is_enabled(node)” now that I found this thread. Might be worth adding to the documentation under either is_enabled or set_enabled to make it clearer disabled nodes are still pickable.
gui.is_enabled
Returns true if a node is enabled and false if it’s not. Disabled nodes are not rendered and animations acting on them are not evaluated.
gui.pick_node - determines if the node is pickable by the supplied coordinates
Disabled nodes are not rendered, ignore animations but are still pickable?