Forum Discussion

Vic's avatar
Vic
Community Member
8 days ago

Automatically resize text box to fit text variables?

Hello.

Has anyone discovered a way to get a text box to dynamically resize to fit the length of a text variable? The text box in question is coloured with an outline and drop shadow and needs to hug the text with even margins. The variable is between 20 and 200 words.

With 'adjust height to fit text' selected, the text shrinks to fit the box rather than the box expanding to fit the text. 

If I oversize the text-box, the text stays the correct size but I end up with massive top/bottom margins on the shorter strings which made our visual designer exclaim "Eeek, no!"

I have tried using a separate rectangle and resizing it using JavaScript (using string length of the variable to roughly calculate the height) but the outline and drop shadow on the text box get stretched (A second "Eeek!" was heard at this point).

Do I need to draw my own rectangles using JavaScript or is there a better way? Am I missing something really obvious? It seems weird that this is so difficult to do!

Thanks!