How to use multible lines in Edit Field with App Designer

47 次查看(过去 30 天)
Hello,
I'm building a GUI with App Designer (MATLAB R2020b) and want to use a Edit Field (Text) with multiple lines (input and output).
When I fill the value of the edit field with a string with \n in it nothing happens.
For example:
text = [test1 \t test2 \n test3 \t test4];
string=sprintf(text)
app.EditField.value=string;
In the edit field is now displayed: test1 test2test3 test4.
I found solutions for this problem but only for GUIDE with uicontrol but this function only works with apps created using the figure function or with GUIDE.
Text Area is not an option because I want to use the same field for input and output.
Thanks for your help!

采纳的回答

Luna
Luna 2021-1-11
编辑:Luna 2021-1-11
Hi,
Try to use "text area" item instead of edit field. When you get the values you can find them in a cell array.
Sample:
line1 = app.TextArea.Value{1};
line2 = app.TextArea.Value{2};
  2 个评论
Maxi
Maxi 2021-1-11
Thanks,
I always thought text area is not editable and could only be used to output text.
Luna
Luna 2021-1-11
编辑:Luna 2021-1-11
I have edited the answer you don't even need to split, if user puts line like below with enter you can get each row in a cell array item. You can also set property of text area editable or not.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by