Appenting text to the end of a textBox

I’m creating an app that receives messages over a tcp connection. At the moment i’m printing all the messages received to the corona console.

Id like to be able to display each message that was received as a new line at the bottom of a text box without clearing the previous lines of text. Similar to the corona console so the user can scroll back through previous received messages.

I’ve added a defaultBox = native.newTextBox to my app and on every message received i update the text value in the text box with defaultBox.text = messageRecived, however this clears any previous text strings.

Any ideas on how to add a new line to the text box without clearing previous entries to give me a scrolling history of received messages?

Try:

defaultBox.text = defaultBox.text .. "\n" .. messageRecieved

Rob

That did the job, thanks.

Is it possible to auto scroll to the bottom of a text box in Corona?

Not that I’m aware of. However, if you don’t need to edit the text, you could use a widget.newScrollView() and add display.newText() objects at the bottom and you can control the scroll position of the scrollView.

Rob

I did just that in the end. Its now working a required. Thanks.

Try:

defaultBox.text = defaultBox.text .. "\n" .. messageRecieved

Rob

That did the job, thanks.

Is it possible to auto scroll to the bottom of a text box in Corona?

Not that I’m aware of. However, if you don’t need to edit the text, you could use a widget.newScrollView() and add display.newText() objects at the bottom and you can control the scroll position of the scrollView.

Rob

I did just that in the end. Its now working a required. Thanks.