Tulkkas
Tulkkas

Reputation: 1013

How to format the text in a textArea component in Matlab so that it always displays the latest value?

I am building a MATLAB app using app designer and I have a textArea component which I use to display output message to the user using the app. The component name is OutputStatusTextArea_1 and i set the value of nb_Text to 0 in the startup function.

Whenever I need to display a message I use the following command:

app.nb_Text                                       = app.nb_Text + 1;
app.OutputStatusTextArea_1.Value(app.nb_Text)     = strcat({'# '},'New Message')

What happened is at some point the number of message fill completely the text area and then everytime i add a message, the user needs to scroll down to see it.

What I would like is to be able to always display the last message at the bottom of the TextArea and that the user needs to scroll up if he wants to see old message. Is there a way to do so?

Upvotes: 1

Views: 1057

Answers (2)

Ivan Demec
Ivan Demec

Reputation: 1

You could make the text area scroll to bottom.

scroll(app.OutputStatusTextArea_1, 'bottom') % autoscroll text area to bottom

Upvotes: 0

FangQ
FangQ

Reputation: 1544

have you tried the setCaretPosition function? see this post

https://www.mathworks.com/matlabcentral/answers/255486-set-edit-uicontrol-to-last-line

Upvotes: 0

Related Questions