Dynamic text displaying

Hello guys,

I’m working on a chat application, and came across an issue. When displaying the received/sent messages I can’t find a way to do it properly.

Here’s what I tried:

  1. Using display.newText() and setting width and height won’t help since I can’t know the height that the text string will have, and this method crops the text that doesn’t fit the height.

  2. Using native.newTextBox() solves the cropping problem, but instead of showing the messages like they should in a chat, it will produce scrolling bars.

Did anyone encounter this problem and has any good solution?

(I could calculate the word warping manually based on each character’s size and determine the height it will require, but I’m looking for a more elegant solution)

Thanks.

you can use the newText object.  set the width your desired valued, but set the height to 0.  If you set a property to zero when it is created it will auto adjust the height to the text and line wrapping for you. 

Thanks gjaman. I missed that line in the documentation.

you can use the newText object.  set the width your desired valued, but set the height to 0.  If you set a property to zero when it is created it will auto adjust the height to the text and line wrapping for you. 

Thanks gjaman. I missed that line in the documentation.