Is there a way to control the ScrollContainer's scrollbars visibility?

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

I want to have the vertical scrollbar of a scrollcontainer always visible. The default behavior is that the scrollbars only show up when they are required. My problem is that when the scrollbar appears because of the child gets larger than the scrollcontainer, it also changes the available size of the container so the alignment gets shifted left.

I tried to understand the mechanism that shows and hides the scrollbars but even by printing the entire property list values of the scrollbar I am not able to see any difference between when it is hidden and when it is shown. The visible property of the scrollbars is always true even when the scrollbars are not drawn.

:bust_in_silhouette: Reply From: Zylann

The vertical scrollbar gets hidden when the height of the contents are small, and it’s a hardcoded behavior:

The only configuration is to hide it always, by setting scroll_vertical_enabled to false.

Visible scrollbars effectively reduce the size of the layout area, which is also not configurable. Here is the code where it plays a role:

The options I see are:

  • Hide scrollbars and make your own outside of the container
  • Change the engine code to adapt it to your needs
  • Add an option to the engine’s code to keep scrollbar visible and make a PR
  • Ask for the feature in the Godot Proposals repo

Thanks for the thorough answer. At least I know that it is a limitation and I can stop hitting my head on the wall. For now I will make the scrollcontainer at least one pixel smaller than his child to make the scrollbar appear all the time. Not a perfect solution but fast amd will allow me to move forward. I have no idea how to do cpp but I will consider requesting the feature.

Ram | 2020-03-20 03:11

:bust_in_silhouette: Reply From: moechofe

By using a custom theme, you can edit the “V Scroll Bar” Class and set an StyleBoxEmpty to every styles using the inspector.

1 Like