cancel
Showing results for 
Search instead for 
Did you mean: 

The last line of text was lost when I use textArea.resizeHeightToCurrentText().

Wrend.1
Senior
seasoningText.setWideTextAction(touchgfx::WIDE_TEXT_CHARWRAP_DOUBLE_ELLIPSIS);
seasoningText.setLinespacing(10);
seasoningText.setIndentation(5);
seasoningText.resizeHeightToCurrentText(); // When I comment out this line, I can see the newline content
seasoningText.invalidate();

I use a textArea and switch off the "Auto-size" option, and put it in a scrollableContainer.

I want it to wrap automatically and adjust the height. But when I use the function "resizeHeightToCurrentText()", the second line is invisible.(When the text area is about to leave the screen, the second line appears)

If I don't use the function "resizeHeightToCurrentText()", the second line will always appear. But I don't know the current height of textArea.:sad_but_relieved_face:

So how can I use the use the function "resizeHeightToCurrentText()" normally?

1 ACCEPTED SOLUTION

Accepted Solutions
Wrend.1
Senior

OK, now I find the reason. It seems like the function "resizeHeightToCurrentText" calc the wrong value for the height and It lead to the last line disappear. I repalce the ​code like this:

//seasoningText.resizeHeightToCurrentText();
seasoningText.setHeight(seasoningText.calculateTextHeight(seasoningTextBuffer)+ seasoningText.getLinespacing());

And it works.

View solution in original post

2 REPLIES 2
Wrend.1
Senior

OK, now I find the reason. It seems like the function "resizeHeightToCurrentText" calc the wrong value for the height and It lead to the last line disappear. I repalce the ​code like this:

//seasoningText.resizeHeightToCurrentText();
seasoningText.setHeight(seasoningText.calculateTextHeight(seasoningTextBuffer)+ seasoningText.getLinespacing());

And it works.

Hi, I get the same behavior with the proposed solution:

 

textArea.setWideTextAction(touchgfx::WideTextAction::WIDE_TEXT_WORDWRAP);
textArea.setLinespacing(3);
textArea.setHeight(textArea.calculateTextHeight(textBuffer) + textArea.getLinespacing());

 

nowrap.jpg

textArea.setWideTextAction(touchgfx::WideTextAction::WIDE_TEXT_WORDWRAP);
//textArea.setLinespacing(3);
textArea.setHeight(textArea.calculateTextHeight(textBuffer) + textArea.getLinespacing());

wrap.jpg