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.