+1 vote

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 'setdisableinput' in base 'Area2D'."

Any suggestions?

in Engine by (436 points)

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

2 Answers

0 votes
Best answer

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.

by (13,682 points)
selected by
+1 vote

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 "ontimertimeout" and "onArea2Dmouse_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 "inputpickable" 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!

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

by (436 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.