How to block signals from buttons that are not visible by Scroll Container?

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

Hi I have a Scroll Container with a vboxcontainer inside, and inside of this vboxcontiner I have a lot of touchscreen buttons.
The problem is that when I add a lot of touchscreen buttons, and the scrollbar is visible, you can touch the buttons that are not visible, so I need to block signals from buttons that are not visible from Scroll container, but I don’t know how to do that because Scroll Container has a few properties.

you can set the button to disabled if you don’t want to make it clickable. is that what you mean?

asetyowatir | 2020-11-19 07:16

Hmm i really like your question made me think for a second.

I know with TextureButton there exists a disable property but with TouchScreenButtons you might have to set _input to false. also TextureButton has the _gui_input() signal which guarantees only that button is being pressed

But if it must be a TouchScreenButton first connect the on_scroll started/exited signal to a script:

func _on_ScrollContainer_scroll_ended():
	var box = Rect2(rect_global_position, rect_size)
	for child in $VBoxContainer.get_children():
		var centre_point = child.global_position + (TouchScreenButtonSize / 2)
		if !box.has_point(centre_point):

Wakatta | 2020-11-19 18:59

No, just figured out that is a bug from Godot

Pelli | 2020-11-19 21:39

Thanks, that worked, but I figured out that is a bug from Godot, if you change the touchscreen buttons to buttons, this problem is solved, so for some bug reason Touchscreen buttons that are not visible inside of a Scroll container can be pressed.
Solution: change to buttons or make this script, thanks man!

Pelli | 2020-11-19 21:43