StablexUI icon indicating copy to clipboard operation
StablexUI copied to clipboard

Make Text grow with container, but not shrink to much

Open RudolfVonKrugstein opened this issue 9 years ago • 2 comments

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.

RudolfVonKrugstein avatar Mar 09 '15 17:03 RudolfVonKrugstein

you need to handle resize event of container. E.g. like this:

<VBox on-resize="
    if ($this.w >= minSize) {
        //resize text widget
    }    
">
...
</VBox>

RealyUniqueName avatar Mar 09 '15 17:03 RealyUniqueName

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?

RudolfVonKrugstein avatar Mar 10 '15 11:03 RudolfVonKrugstein