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.

asked Feb 19 in Engine by Fenisto (63 points)
edited Feb 19 by Fenisto

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 How to use this Q&A? before posting your first questions.