I am using ‘appdesigner’, I would like to programmatically scroll to the bottom of a TextArea, is this possible?
13 次查看(过去 30 天)
显示 更早的评论
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
1 个评论
Eric Sargent
2020-12-9
As of R2020b uitextarea now supports scroll.
In this case you could use:
scroll(textArea, 'bottom')
回答(4 个)
Michael Corbett
2018-10-12
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)
consoleObj
end
- 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};
end
- Call the function to display the new text.
writeConsoleLine(app,'Pushbutton pressed');
3 个评论
Jan
2019-2-14
@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
2020-6-12
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?
Joshua Welsh
2018-4-16
Put your text into a ListBox instead of text area and then use the scroll function:
scroll(app.ListBox, 'bottom')
3 个评论
Rayan Alkashgari
2019-3-7
This works in Matlab 2018b. Make sure to pause after adding an item then execute:
app.ListBox.scroll('bottom')
Han Geerligs
2017-6-9
Hi Gregg,
I have the same question. Do you have any solution already?
regards, Han
0 个评论
Eric Sargent
2020-12-9
As of R2020b uitextarea now supports scroll.
In this case you could use:
scroll(textArea, 'bottom')
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!