Topic was automatically imported from the old Question2Answer platform.
Asked By
stubbsy345
I am working on the master branch of Godot with the textEdit node that is now able to wrap. I want to be able to expand the text edit node if the user writes greater than its initial size. However, I currently can’t find a way of 1) disabling v scroll or 2) detecting the number of lines wrapped. get_line_count does not treat wrapped lines as a new line so I am not able to do it this way.
Hello!
There is no built in function for that, but there is a way around:
For each line, divide the text width by the (TextEdit width minus the scrollbar width), and it gives you the number of actual lines.
Here is a code snippet:
I first get the line spacing constant, depending on whether I use a theme, or custom constants. Then, I get the font and calculate how high is a line of text. At the end, I use _get_real_line_count() to know how many lines are displayed.
The _update_height() function is to expand vertically the TextEdit’s size.