+3 votes

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 ?

in Engine by (176 points)
edited by

2 Answers

0 votes
Best answer

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.

by (176 points)
edited by
0 votes

Simply set the buttons "disabled" as when you hide tchem.

by (444 points)

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.

Then disbale them too?

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.