[UMG] How can I get the ScrollBox's maximum offset?

I have a scrollbox within a Horizontal box and I’m trying to scroll manually using GetScrollOffset and SetScrollOffset, but I can’t find a proper value for the maximum scroll so it goes past the max and takes a while to come back up.

GetDesiredSize.Y is too large a value and casting to canvas panel slot returns size 0,0.

Any help is appreciated!

I would like an answer too! Had to cut a feature because I couldn’t figure this out and I can’t wait around for a solution.

How can Blueprint users manually change the scroll offset - particularly scrolling to the end as the user sees it and not merely as Slate recognizes it? I had the exact same problem as OP.

Hi,

The maximum scroll distance is the desired size - the actual displayed size.

Here is my method for scrolling down with a game pad

1 Like

Hi ajarman88, thanks for the reply :slight_smile:

I haven’t tested this in 4.10, but this is precisely what doesn’t work in 4.9 in my scenario (GetSize returns 0 for the scrollbox and GetDesiredSize returns the size of the full content)

Hi Grogger,

Is your scroll box an immediate child of the canvas?

If the scroll box is parented to a horizontal box for example, getting the canvas size directly will return 0 as the scroll box is not on the canvas.

The hierarchy below will cause the canvas size to return 0, for this you would need to get the size of the horizontal box on the canvas.

76500-canvas+parent+1.png

However if the scroll container is parented directly to the canvas, getting the canvas size should work, as it does in my case.

76521-canvas+parent+2.png

Yup, that’s what’s happening. The workaround works great (thanks), though it’s unfortunate that it doesn’t return the proper size on the control - I’m using inheritance, so the function will be reusable, but the widgets won’t be the same.

Thanks again, I’m using this workaround for now :slight_smile:

ajarman88, you are glorious. This has worked great for what I need!

in case someone is coming by that is wanting to use this to set up the maximum scroll value in a configuration step on construct, you cant, it will return 0 for desired size, just do it 2 frames later

Here a solution if your scroll box is not in a canvas pannel. Overlay Stats being the upper hierarchy of my scrollbox

The selected and upvoted answer has not worked for me; after subtracting off canvas slot sizes for parent widgets I’m still consistently left with too large of a Maximum offset.

After further investigation with the help of someone on the Unreal Slackers Discord it appears that subtracting parent canvas slot sizes are not actually providing the size of the visible geometry for ScrollBoxes inside other container/parent widgets.

The solution for these cases is to make use of the CachedGeometry exposed to blueprints for the ScrollBox and getting the local size, as so:

1 Like

Great solution! Only this working perfect in my case (solutions which uses Canvas are always returns with errors, despite they are actually worked). Thank you!!!

float UScrollBox::GetScrollOffsetOfEnd()

↑ Use This!