How can I retrieve a actual textField.height?

Dear community,

how can I retrieve the actual height of a textField?

textField.getBounds(),
textField.getRect(),
textField.height

… return 100 for a textfield, that is not multiline and has a fontSize of 12.

KInd regards
Arnim

Try textField.textHeight + 4

Thank you for your reply, Joshua.

What does the ‘4’ stand for? Is it the textfiled’s padding? How can I get/ set this one?

Except for the little unsharpness of the anti-aliasing effect, the textHeight is accurate.

But the textWidth only seems to return the width of the biggest letter…

How can I retrieve the accurate width of the whole textfield?

I would like to limit the extends of the textfield to its minimum.

Otherwise I would get odd effects, when triggering it…

textWidth and textHeight should match the inner (actual) dimensions of the text content within the TextField. The +4 is because TextField is hard-coded to give a 2 pixel gutter on all sides. This is not configurable

Thanks again for your reply.

Ah, yes. I see.

I am not sure, what went wrong before, but now I get the proper results.

Kind regards
Arnim

1 Like