Dynamic height of components in a container


I’m new to Juce and I have a question I couldn’t find the answer to on the forums, I guess its just something I don’t understand yet.

I’m looking for the best way to do the following:

I want some container to hold 10 TextEditors (with some different starting text in them), one above the other, so that each TextEditor will have exactly the minimum height required to not need a scroll bar and a fixed width.
The container itself should have a fixed width (same as the TextEditor’s fixed width), and exactly the minimum height to hold the 10 TextEditors, after the TextEditors have been resized to not have a scroll bar.

I’m not looking for the code to do it, but the components hierarchy and key logic to achieve this.

Thank you!

I guess you’d just stick your TextEditors in a component, and whenever their content changes, you’d figure out its new size. Your parent component could override Component::childBoundsChanged to find out when it needs to update its size and layout.

When you say figure out its new size, do you mean I should multiple font width with number of characters etc…? I can’t see any other way…

Yeah, the TextEditor isn’t designed to provide that kind of info. Not sure what’d be the best suggestion for doing what you’re trying to do…