This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have several control nodes that via signals execute some code when I mouse click on them. Lets say they set a var value to 1 or 2 based on a node.
Can I somehow set this var for example to 0 by clicking outside of those node? Without making another control node or a collision area. Or mouse coordinates.

in Engine by (88 points)
edited by

What about setting up a master node for all those nodes. Then, whenever one of them is clicked, they send a signal to the master node telling it which of them was clicked, and it changes the variable to whatever the corresponding value is (1, 2, etc.). If it detects a mouse click (via the normal Input.is_action_just_pressed method), but doesn't get any signal, it just changes it to the neutral value (0).

It's a little sketchy though, there might be a better way to do it.

Thanks. A worthy idea. But what I'm doing supposed to have a lot of ui elements. Would need to add everything. But still works that way too I suppose.
Basically just need to make a full-pledged UI and not some separate pieces. Which needs to be done anyway

Solved it for my case by having a general input event and in it I change the var by a right click

func _input(event):
   if Input.is_mouse_button_pressed(2):
      var = 0

Please log in or register to answer this question.

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.