Random beginner-question #5: Disable input only for node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pferft

Hi everyone,

I switch off input for a button while it animates using "get_tree().get_root().set_disable_input(true)". As this unfortunately switches off input not only for the button-node but for the whole scene, is there a way to confine this on the node alone?
I tried "get_node("ButtonArea2D").set_disable_input(true)" but that leads to “Invalid call. Nonexistent function ‘set_disable_input’ in base ‘Area2D’.”

Any suggestions?

Did you try to disable input in the properties of the button?

rahsut | 2020-08-17 14:21

:bust_in_silhouette: Reply From: jgodfrey

The typical way to disable a node would be to set its disabled property to true.

So, assuming you have a valid reference to your button in Button below, then…

$Button.disabled = true

Note, this will render the button in a disabled (grayed-out) state. But, I’d think that’s what a User would expect for a disabled input control.

:bust_in_silhouette: Reply From: pferft

Thanks for your answers, rahsut and Jgodfrey!

My bad, it’s not a “button” in that sense, I should have elaborated that earlier. It’s a self-made “button” (Area2D - CollisionShape2D) including several functions like “_on_timer_timeout” and “_on_Area2D_mouse_exited” and alike. There are things happening within each of them like animations including yields, and during those I’d like to have any input disabled. So I guess “button.disabled” won’t work in this case.

I’ve been looking into “input_pickable” before, because I think that might be what I need here. Probably a typical beginner-issue, I just couldn’t find out how to build it into my script! (I, the brginner, sometimes stumble over things, like in the documents, that look exactly like what I need, but I have no idea yet how to implement them. If only there were little examples shown in those places… I’m certain most beginners know that feeling.)
Could you tell me how I can actually “use” input_pickable?

Thanks for your help!

I just learned: get_node("your_area2D").input_pickable = false does the trick!