Is it possible to update a uitextarea without using drawnow?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi all,
I am building an app using the app designer, in the window I have a uitextarea where I post updates to the user, something like this:
app.OutputTextArea.Value{end+1} = sprintf('Hello world');
I can also programatically scroll the text area down so the user can see the lastest message:
scroll(app.OutputTextArea,'bottom');
However, if the code is running quite quickly many messages are not shown until the current task is completed, at which point the text area is updated all at once, which defeats the purpose of giving the user a current status update.
drawnow;
But as I understand it this updates all of the displayed items, which is a waste of resources when the only thing changing is the text area.
I would like to just update the text area and nothing else.
Drawnow does not accept an axis as an input, so I can't tell it to just update one thing, however I have tried refreshdata which can accept a specific axis input:
refreshdata(app.OutputTextArea);
However, this doesn't seem to work for uitextareas.
Is there a function I am unaware of that does what I want? Or should I use something other than a uitextarea to update the user?
Thank you for any suggestions.
댓글 수: 1
Walter Roberson
2023년 5월 6일
My understanding is that there are internal "dirty" flags that optimize not having to reprocess graphics objects that have not been changed (it gets a bit more complicated than that because overlayed graphics can be affected by underlays changing.) So if the text area is the only thing that has changed, then processing drawnow should not be expensive.
I could be wrong about the internal workings.
답변 (1개)
Image Analyst
2023년 5월 6일
Not that I know of, other than putting in a pause(), which would just slow down your app also. Sometimes what I do is to call drawnow only every, say, 20th iteration
for k = 1 : 100000
if rem(k, 20) == 0
drawnow;
end
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!