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