StablexUI
StablexUI copied to clipboard
Make Text grow with container, but not shrink to much
Can I configure a "Text" widget, so that it grows in width with the container Widget (a VBox), but also forces the container to not shrink below a minimum size (so that it is always able to contain the complete text)?
<VBox id ="'container'">
<Text .../>
<MoreWidgets .../>
</VBox>
When I set widthPt="100" on the Text Widget, it does not enforce the container to grow, when the text does not fit anymore. When I do not set "widthPt" the Text widget seems to have a fixed size, which exactly with the text.
you need to handle resize
event of container. E.g. like this:
<VBox on-resize="
if ($this.w >= minSize) {
//resize text widget
}
">
...
</VBox>
I see, thanks. I would prefer to do this in the "on-resize" of the text widget (because it feels more like a property of the text widget). Can I access the "w" and "h" parameters of the on-resize function in xml?