Inverse sorting to a UMG scroll box when "add child"

I got an blueprint UMG with a blank scroll box.
In my game, sometime, there will have text appearing in that scroll box by “create widget” and “add child” (to the scroll box).

Its working but,
I want each next new created widget to be add to the top of the list.
Like a facebook page news feed :wink:

i tried with an array and insert but i wasn’t able :frowning:

thx alot in advance

Off the top of my head:

  1. Make a “placeholder array” and have array index 0 as your new entry.
  2. Run a for loop that feeds each index of your original array into the “add array element function” (or whatever the the equivalent is called in blueprints).
  3. Clear your original array.
  4. Feed your placeholder array into your original array.

Good luck!

i tried something like that, it didnt work.

my scroll box is showing my array of text
I used “insert array” and “add array” to try to sorting my new feed with integers.
like 1 on top and -1 to new feed created.

I think you misunderstand my suggestion. Try rereading the thing step by step.

And you cant “insert” an index at -1. Arrays start at index 0 and go from there. I highly recommend you google arrays and/or “zero-based index” to get an understanding of how they work.

I don’t think you can directly insert a child widget into a *scrollbox *at index 0. I would not insert messages into an array either or keep a dummy. Keep the array with the text as is; but rather than looping from index 0, loop from the last element to the first one and create widgets as you go. This way, your last array index will be the first *scrollbox *child.

There’s a caveat here, you will need to clear and repopulate the entire scroll box when adding another child. If you want to keep thousands of entries there, consider handling the last couple of dozens only.

MA Log is the scrollbox reference.

ah nice !
thx @6icpool @Everynone.

ill try that soon !

I cant make a widget with a log line text …
how do you create that variable slot ?

i just have Class and Owning Player

i found a way to get it work !

i use “Add to array” and " insert to array "

but like @6icpool @Everynone has said,
i needed to clear my children before creating my new widget.

i insert my new widget to the array at 0 index.
and i re-created my scroll box with “for each loop”

so each time a got new things in my array, i insert them at the top (index 0).

:slight_smile: thank alot !

Glad you made it work mate :slight_smile:

One trick to avoid all this madness:

  1. set the list scale to -1
  2. set the children elements scale to -1
  3. enjoy
2 Likes