New UI Scrollview with Text Widget, how to set dynamic height?

I’ve a scrollview with a dynamic text. Direction vertical.

I set the contentSize of scrollview, then create the Text widget, configure it and add as child of scrollview like the example in the wiki.

Now I have to set fixed width as the scrollview width but the height is variable with the text that dynamically is loaded.

How can I achieve this?
I’ve tried with getTextAreaSize, getContentSize, getVirtualRendererSize, but nothing…

Please help me to trying to find the height of this text to initialize runtime the innercontainersize of my scrollview.

Thank you.

Nobody can help me? :frowning:

Consider using ListView. It automagically handles its own size depending on the size of its children.

1 Like

Thank you dotsquid for answering me.

Interesting idea, I’ll try immediately, a listview with just 1 Text item. I’ll keep you updated soon.

Actually I believe it’s a major issue that there is no easy way to get immediately the real size of the text.

Yes I think it’s a major issue too.

Anyway I’ve tried with ListView but I think that I have the same problem or I don’t know how to handle it.

The Text widget is added to a Layout item and then to a Listview like the wiki says.
But now I have to set fixed width for the item and I don’t know how to set the dynamic height for the text.
Otherwise the text widget has a bigger width and the height is like the number of lines the original txt files has.
If I use the setContentSize I have to specify both width and height.

So, what to do? :\

I’ve solved reading this old post: Ui::Text widget does not wrapp lines? - solved

Using Label::createWithSystemFont it correctly get the real height of the text.
And then I use this height for the Text widget.

I know it is not a good way of coding, but if somebody has a clever idea please write it :slight_smile:

Thank you.

BTW. However I open an issue on github, it’s better.