Dynamically adding children to a scroll box?(From the top down?)

I’m creating a message log to catalog events as they happen. Game start, new day, any event etc. Think of this like in civ or something.

I want to make it so when a new child widget is added to the scroll box in my hud it will be added to the top and push the last one down. Unfortunately there is no simple way to do that in ue4. I am attempting to add the widget to an array and then add each child again, saving all the info in arrays along the way.

For some reason my for loop doesn’t seem to iterate at all though, it just instantly fires the complete. I just have the initial event hooked up to a timer on begin play that loops every 5 seconds so I can see a new game start message every 5 seconds.

Any help appreciatted.

Edit: Grammar

This is one of my pet peeves, such a weird omission in UMG.

it will be added to the bottom.

I believe you mean to the ‘top’, seeing how you’re forced to use the array insertion workaround. Not sure why the loop is not iterating (no need to cast, btw) - maybe it is but the children do not appear?


Do consider the following alternative, there’s a hack that works surprisingly well:

  • add a Vertical Box to the Scroll Box and rotate it 180
  • when adding children, add them to that Vertical Box instead, and also rotate them 180

This way the Scroll Box behaves normally (since it is not rotated) and new elements pop in at the top. And you do not need to fiddle with an array or clear the container:

Image from Gyazo

…such a weird omission in UMG.


edit:

From the bottom up

Or is literally from the bottom up, as in the container is aligned to the bottom and new notifications push the stack upwards?!

10 Likes

No I’m just stupid and missed typed, I meant top down. Thanks for the answer an easy workaround that fixed my issues immediately.

I feel baffled, because I seem to be getting the opposite behavior as everyone else. Adding a child appears to put the child at the bottom rather than the top for me, and I want the opposite behavior. Maybe I’m just misreading edits at this point.

This hack seems silly, but it indeed works for me. Thanks.

Hi I had the same problem I was trying to put an email list with the new emails at the top this is what I’ve used to solve the issue

Thanks this works very well

Genius)