Restrict input events to area of control node

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

Hello,

I am attempting to code for touchscreen input; there are two different ways that I am processing input.

I created two different scripts to attach to control nodes; one processes the input in one way, and the other script processes the input in a second way. As an example, a mouse click might print “A” to the output in the script one, and a mouse click might print “B” to the output in script two.

I can get the scripts to work. If I place them in the same scene (on different control nodes), they will both process the input: “A” and “B” will both be printed to the output.

What I wish to do is limit the input processing to one of the two scripts depending on where in the viewport the mouse click occurs.

I have tried, for example, creating two control nodes and set the size to give two rectangles - say each covering half the viewport. However, it doesn’t matter in which control node rectangle the mouse is pressed, both will process the input. I can’t find a way to limit the input processing to a particular script, with the particular script dictated by the location in the viewport in which the event occurs.

There must be someway to limit which script processes the input determined by the location in the viewport in which the event occurs?

:bust_in_silhouette: Reply From: _func_jay

Managed to get it working with:

func _gui_input():

Input events propagate up the tree and can be captured by particular control nodes before others if _gui_input() is used.