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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 24 Set 2015
  3 Commenti
Walter Roberson
Walter Roberson il 24 Set 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 il 26 Set 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by