I’m making a pop-up window describing the properties of an item, and its size depends on the information. It ended up looking like this one, using both Horizontal and Vertical boxes so it automatically adjusts its size around the inner texts.
However, the “Size” value of this widget remains constant, as you can see in the green rectangle, and I cannot anchor and align this other than the top-left-based. If I try to align it against the bottom right, it will end up like this.
While not without flaws and its own somewhat rigid ecosystem, It is one way to automate the process. Afair, it handles pop-ups going off-screen automagically.
Yet another way to handle pop-ups is via a menu anchor widget:
small note: getting DesiredSize get calculated on the next tick, so you need to either add a delay or use of ForceLayoutPass(a bit expensive) if you want it to be in the same execution/tick.
If it’s already sitting in the canvas, flag it as Size To Content. And yes, Force Layout Prepass should work well here. But use it only when the widget is glitching as its size is adjusting. Or you see text spilling out of containers.