MATLAB: Copying text from edit box in GUI to matlab report.

matlab guireport generator

I have created a GUI in which there is an editbox where user enters certain text. This text is then required to be added in a report which is generated at a later stage. I am using a code which is something like this:
%%Code to get text entered in editbox
handles.text=get(handles.editbox,'string');
%%Code to add text to matlab report (via DOM API)
text_to_be_added=Paragraph(handles.text);
append(report,text_to_be_added);
Now my problem is as long as the text entered in editbox is a single line the result is fine (Text is copied as it is from editbox to report). But if I add a new line in the text which is to be entered in editbox (by pressing enter key), the text which is printed in report is totally disoriented.
Eg: If the text in edit box is: This month is july. Then the text saved in my report is: This month is july.
But if the text in edit box is:
This month is
july.
Then the text saved in report looks like this:
Tjhuilsy .m o n t h i s
Is their any way this problem can be fixed. I know adding '\n' rather than pressing enter key will add a new line in report but is their any other way in which matlab can recognize enter key press to add a new line automatically.

Best Answer

Sudhanshu - you mention that typing \n works. Can you perhaps inject this character after the user has typed in the text into the edit box? Note that
handles.text=get(handles.editbox,'string');
will be a cell array of strings, one for each line in the edit box. So you could create a single line string from these multiple strings, concatenating each together and separating each by a \n. For example,
strData = get(handles.edit1,'String');
handles.text = strData{1};
if size(strData,1) > 1
for k=2:size(strData,1)
handles.text = [handles.text '\n' strData{k}];
end
end
However, I don't know if this will be sufficient when adding it your report.