[bugreport] scrollbox with auto size won't scroll

Hi,

I am dynamically filling a scrollbox. I noticed that if i set the size of the scrollbox to auto it won’t scroll anymore. While debugging it seems to conclude it doesn’t have to, although a large part of the scrollbox is clearly not visible on my screen. If i set the scrollbox size to fill instead it works fine.

Is this expected behavior?

Thanks!

I would expect this to happen yea. Wrap your Scrollbox with a Sizebox that has the desired width/height, so the Scrollbox can’t exceed that size and will be scrollable…

helpful !! thinks :slight_smile:

Hi I’m going to bring this back as I’m having the same issue with the scroll box overlapping it’s parent widget, but my since I’m doing this dynamically I can’t use the size box solution. Could there be a more robust solution? I would’ve assumed SScrollBox would’ve took its parent’s size (minus siblings) desired sizes into account when decided on its own desired size?

You can use ConstructObject for widgets like SizeBox, VerticalBox, Button, …, all widgets that come from slate.

I look into this today as I wanted to fix it for our project. Problem with the Auto-Size is that nobody knows how much space to give that widget, so the widget is given its DesiredSize. In case of the ScrollBox, the DesireSize is the size of all its child widgets.

Still, when the widgets exceeds the screen, the size given to the widget should be clamped to the possible size where the widget can be contained. This would make a ScrollBox still render over all widgets that are placed after it - in case the ScrollBox exceeds the possible space - but it would at least be renderable and work properly when it is the last widget in e.g. a VerticalBox.

The problem is in

SBoxPanel.cpp

template<EOrientation Orientation>
static void ArrangeChildrenAlong( const TPanelChildren<SBoxPanel::FSlot>& Children, const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren )

If you have a custom build of the engine, you can fix that. If not, only giving the widget a fixed size will help (Fill, SizeBox).

The logic for giving space to child widgets is implemented as:

  - Calculate the FillFactorCombined from all widgets with Fill-Size
  - See how much space all widgets with Auto-Size need ->AutoSizeCombined (DesiredSizeCombined)
  - Calculate the LeftoverSize which is AllottedSize-AutoSizeCombined
  - Give all widgets that are set to Fill the size: LeftoverSize*FillFactor/FillFactorCombined
  - Give all widgets with Auto their own DesiredSize