I'm trying this in Godot 4:
# A helper for making a scroll container in a tab bar
# follow the selected tab button.
class_name PS3TabBarScrollFollow
static func apply(tab_bar: PS3TabBar, container: ScrollContainer) -> void:
tab_bar.tab_changed.connect(func(_tab):
var btn = tab_bar.current_tab_button
container.scroll_horizontal = (btn.global_position.x - container.global_position.x))
It works, however it changes the position abruptly if you use the scroll bar with a mouse scroller for example. follow_focus
has no effect since I had to implement custom tab bar buttons without using focus.
I think I'm missing a simple condition here. Something like this:
if btn.not_clipped_by(container):
# do something
...
Does someone have a little logic here?