Scrollbox slate


How does slate scroll bar work and how can I add content to it?

I have a container containing a lot of horizontal and vertical widgets.
I want to limit its size and add so that it can be made scrollable. How can I add a scrollbox in slate

Something like this doesn’t work

		.Padding(FMargin(37.5, 37, 38.5, 37.5))

I haven’t nosed around the internals of the SScrollPanel much and “Something like this doesn’t work” is rather vague ;). So I don’t have specific debugging leads, but try poking at it with the Slate widget inspector to see what’s happening.

Based on what I do know, if you’re familiar with how Slate lays out its widgets, then scroll panel is obviously a special case. Unlike other panels, it can’t just sum up the desired sizes of its child widgets to figure out its own size, because then it would end up requesting the full size of its widgets, which wouldn’t result in a smaller scrolling area than the underlying widgets. Therefore, having a SScrollBox in a non-fill align can’t possibly resolve into a smaller size that will result in scrolling.

Whatever approach you use has to result in the SScrollBox requesting its own size rather than inheriting its children’s. Try setting that SBorder to HAlign_Fill (for vertical scrolling) or VAlign_Fill (for horizontal scrolling), and adjust the padding values until you have the positioning that you want. Alternatively, you can wrap the SScrollBox into a SBox with size overrides. The latter is what I did for the news box for our game:

SNew( SBox )
.HAlign( HAlign_Left )
.VAlign( VAlign_Bottom )
.Padding( 40.0f )
.WidthOverride( NewsStyle.BoxSize.X )
.HeightOverride( NewsStyle.BoxSize.Y )

	SNew( SScrollBox )
	.Style( &NewsStyle.ScrollBorderStyle )
	.ScrollBarStyle( &NewsStyle.ScrollBarStyle )
	+ SScrollBox::Slot()
		SAssignNew( NewsEntriesBox, SVerticalBox )

Edit: I’m poking around this news widget using the Widget Reflector, and sure enough, the SScrollBox is reporting a desired size large enough to encompass the entire news entries list. If I remove the size override, the widget ends up taking up the entire screen save for the 40 point padding. Because that is still not large enough for the news contents, it ends up scrolling anyway.