The component tutorial shows how objects can be sized and positioned according to the container that they are a part of. Although this is the default behavior, the parent of an instance can be explicitly set to another instance.
This functionality is useful for
For this example we’ll create a Text object which includes a value and a unit of measurement. Specifically we’ll create two text objects - one will display a numerical value, the other will say “feet”. We will use two text objects so that we can independently color them.
To do this:
Next we’ll make the UnitsDisplay use the ValueText as its parent:
Next we’ll want the parent text (ValueText) to automatically size according to its contents. To do this, set its Width to 0. Setting Width to 0 on a text instance means that the text’s width will be equal to the size needed to display the text.
Now that we have the texts set up, let’s modify the color of the UnitsDisplay:
Now the Text variable in ValueText can be changed, and when doing so the UnitsDisplay will automatically change positions: