UMG Verticle box Add child at index

I want to add children to a vertical box at a specific index at runtime. Currently all I can do is “Add child”, and it just adds the element at the top of the list.

I looked through the code and found that there is a “ShiftChild” function in c++ that is used in the editor for rearranging widgets. But it’s apparently blocked by a #ifdef for use with the editor only. This is the case in 4.8 as well.

How can I do this then? Ideally I’d like to do it in BP, but if there’s a way to do it in code I can easily make a BP node or something.

The only reason that function exists is for the editor is because we completely rebuild the slate widget when the structure changes, so it’s safe to restructure it. Not every kind of slate panel understands inserting at runtime.

Personally, I’d probably consider building a different kind of panel. Guessing you’re making list of scores or something you’re constantly trying to re-sort? I’d probably build some kind of SPriorityBox in slate, where there’s some arbitrary priority value the panel sorts by before drawing.

Otherwise, I would suggest making engine modifications to add the function to vertical box. The fields you need to are protected, so just making a C++ function to do it, isn’t really an option.

Are there any plans to add the ability to re-sort panel children at runtime? (Even if only for a certain panel type) Since I am not good at C++ nor do I know slate, I currently have to delete and re-add panel children to re-organize them at runtime; Ok if it’s a small amount of children, but can be bad when there is a lot.

2019 still no solution for this.

If it worth something, I solved this problem by firstly ordering my array, not ordering the vbchilds, once my array is ordered, insert it as you wish.

Any way to put child on top when i’m using scroll box?

I know this is old, but I recently found out a stupid workaround that works in C++, and might work in BP.

When you want to rearrange the WidgetPanels’ children, try this:

  1. Copy all the children of WidgetPanel into a temporary array, tempArray
  2. Sort this new tempArray as you desire
  3. Clear the WidgetPanel’s children
  4. Add the elemenys of tempArray back into WidgetPanel as children.

The hack in this answer worked well for me. Re-creating a list every time doesn’t work for me, since it seemed to stop animations.