Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How best way to resize textfield to fit all text

I got a textField (html text) that is very dynamic, and I have to resize the box to fix it and calculate the space occupied. I'm using...

myTextField.height = myTextField.textHeight;

But the result is not very precise, even the Adobe description says that is not. There is a better way to do it? There is some "auto resize" propriety of this class? And for the last: what is the purpose of this "textHeight" if it doesn't provide the real text height?

like image 941
Gustavo Avatar asked Dec 12 '22 14:12

Gustavo


1 Answers

TextField class has a getLineMetrics() method which returns TextLineMetrics.

There are nice examples on both pages.

You can get the number of text lines in a multiline text field with numLines() method.

enter image description here

like image 108
sanchez Avatar answered Dec 22 '22 07:12

sanchez