Long string inside a static text which will pass on to another string when Push button is used

조회 수: 1 (최근 30일)
Hello Matlabers I am trying to find a way to turn my program into a GUI. The challenge I am faced with is that there is a lot of text in my program and I need to show these text in a static text. Also I want to assign a push button which will allow the user to pass on to the next sentence or paragraph (since the text is just too long to be seen at once and it reduces readability). I'm not that experienced.

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 24일
  댓글 수: 3
Walter Roberson
Walter Roberson 2015년 9월 24일
The above link describes implicitly how you can have a push button change the scroll position of a multiline text box.
If your task is instead to have the pushbotton change the text box to show the next paragraph, then create a cell array of cell array of strings, and have a counter variable going (perhaps stored in the UserData of the box) and have the callback increment the counter, fetch the cell array of strings corresponding to the counter value, then set the String field to the text. For example,
paragraphs = {{'this is a short paragraph'};
{'this is paragraph 2 line 1', ...
'this is paragraph 2 line 2'}};
paranumber = get(handles.editbox1, 'UserData');
if isempty(paranumber); paranumber = 0; end
paranumber = min(paranumber+1, length(paragraphs));
set(handles.editbox1, 'UserData', paranumber);
this_paragraph = paragraphs{paranumber};
set(handles.editbox1, 'String', this_paragraph);
Paragon
Paragon 2015년 9월 26일
thank you this is helpful, indeed. Still it will be really hard for me since i have a lot of text. But i am going to use this method if i could not find any other.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by