MATLAB Answers

I am using ‘appdesigner’, I would like to programmatically scroll to the bottom of a TextArea, is this possible?

120 views (last 30 days)
Gregg Swanson
Gregg Swanson on 28 Apr 2017
Commented: Samuel Salinas on 12 Jun 2020
I am using ‘appdesigner’.
I would like to programmatically scroll to the bottom of a TextArea, is this possible?
My text area is being used a "console log".
Thanks, Gregg


Sign in to comment.

Answers (3)

Michael Corbett
Michael Corbett on 12 Oct 2018
To accomplish a scrolling text area, I did the following:
- Create the Text Area with 3 lines high (or as many as you'd like).
- Create a public consoleObj object using
properties (Access = public)
- On startup, write lines one and two (change to whatever appropriate):
app.consoleObj.line1 = 'Console Started';
app.consoleObj.line2 = 'System ready';
app.consoleObj.line3 = '';
app.ConsoleTextArea.Value = {app.consoleObj.line1;app.consoleObj.line2;app.consoleObj.line3};
- Wrote a function that would replace line1 with line2, line2 with line3, then add the new line3 and display:
methods (Access = public)
function writeConsoleLine(app,lineIn)
app.consoleObj.line1 = app.consoleObj.line2;
app.consoleObj.line2 = app.consoleObj.line3;
app.consoleObj.line3 = lineIn;
app.ConsoleTextArea.Value = {app.consoleObj.line1;app.consoleObj.line2;app.consoleObj.line3};
- Call the function to display the new text.
writeConsoleLine(app,'Pushbutton pressed');


Jan on 14 Feb 2019
@Marko: Please use flags only to inform admins and editors about content, which might conflict with the terms of use, like spam or rudeness. Thanks.
If this answer solves your problem, "accept" it instead of setting a flag.
Samuel Salinas
Samuel Salinas on 12 Jun 2020
I tried the same approach but the "app.ConsoleTextArea.Value" field demands a string scalar or charcater vector, not a cell.
How do I go around this?

Sign in to comment.

Joshua Welsh
Joshua Welsh on 16 Apr 2018

Put your text into a ListBox instead of text area and then use the scroll function:

     scroll(app.ListBox, 'bottom')


Marko Antila
Marko Antila on 14 Feb 2019
Unfortunately this does not work, at least in App Designer in Matlab 2018b. Scroll function at callbacks does nothing, and in startupFcn it hides the List Box permanently. Hope this bug will be ironed out in near future. Or even better, a console component will be added to the component library.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!