Autoscrolling in a TextEditor when using setText


I created two TextEditor components, one for user input and the other for text output, like a chat. The problem is that when I add text to the output TextEditor (via setText method), autoscrolling does not work. It works only when I put text directly into the output TextEditor.

Is there a way to get autoscrolling to work in this case? Here is a sample code of what I need to do:

	void textEditorReturnKeyPressed(TextEditor &editor){




move the caret to the end of the text?

Thanks, Jules!

Is there a way to get the TextEditor length without store it in a string? Actually I’m doing this:

String text = chatOutput->getText();
int size = text.length();

well you could just do chatOutput->getText().length().

String contents are reference counted anyway though, so it’s not like it’s actually copying the entire contents to a new variable. I guess the decision you have to make is “do i want the line where i call chatOutput->setText() to be made longer by using chatOutput->getText() as the first parameter too?” :slight_smile:

If it’s for finding the end, just call setCaretPosition (INT_MAX)