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

3 views (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 24 Sep 2015
  3 Comments
Walter Roberson
Walter Roberson on 24 Sep 2015
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 on 26 Sep 2015
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!