How to clip input events to the size of a parent control node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ulty
:warning: Old Version Published before Godot 3 was released.

I’m trying to make a custom scroll container. Partially hiding the buttons inside it I do via

func _draw():
	VisualServer.canvas_item_set_clip(get_canvas_item(),true)

This works well so far, but the invisible buttons can still be clicked.
Is there a way to limit the Input events so that children of the container node only receive input events when they are inside the area of the parent container node ?

:bust_in_silhouette: Reply From: KRL

Simply set the buttons “disabled” as when you hide tchem.

That only makes sense for buttons that are completely outside the container, buttons that are half in and half out would be very irritating for the user to be disabled or clickable on their invisible part.

ulty | 2016-03-19 08:14

Then disbale them too?

KRL | 2016-03-19 09:46

:bust_in_silhouette: Reply From: ulty

Ok, so here is how I did it for now (c++).
We just need to expose a built in constant function to set its value in gd script.

added the following lines of code to the control .h public section

bool clips_inp;
virtual void set_clips_input(  bool clip_i);

added/inserted the following lines of code to the control .cpp

bool Control::clips_input() const {

return clips_inp;
}

void Control::set_clips_input( bool clip_i){

clips_inp=clip_i;
}

Control::Control() { ...
clips_inp = false; }


void Control::_bind_methods() { ...  

ObjectTypeDB::bind_method(_MD("set_clips_input","clip_i"),&Control::set_clips_input); }

now we can set clip input in every control node with gd script:

set_clips_input(true)

had to re add some of the affected nodes in the editor after recompiling for it to take effect.