2020-12-01 05:11 PM
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?
Solved! Go to Solution.
2020-12-06 10:02 PM
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.
2020-12-06 10:02 PM
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.
2023-07-20 05:27 AM
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());
textArea.setWideTextAction(touchgfx::WideTextAction::WIDE_TEXT_WORDWRAP);
//textArea.setLinespacing(3);
textArea.setHeight(textArea.calculateTextHeight(textBuffer) + textArea.getLinespacing());