I have a ScrollContainer with a VBoxContainer inside. I add new nodes to the VBoxContainer from code and I want the ScrollContainer to scroll to the last one from the code. This proved to be surprisingly complicated, mainly due to the fact that GUI gets updated on the next frame, so I cannot manipulate the scrollbar in the same place that I've added the node;
I tried using GrabFocus()
and :
ScrollContainer.ScrollVertical = (int)ScrollBar.MaxValue;
but the first causes the scrollbar to scroll to the top and second to scroll to the previous last position.
I've read that in GDScript I can do this before further manipulating the GUI:
yield(get_tree(), "idle_frame")
and the C# equivalent would be:
await ToSignal(GetTree(), "idle_frame");
but it appears to block execution of the code forever.
How to properly await idle_frame
from C# or at least wait for the GUI to have been updated (the right way).