Simulink Mask newline or line feed in Static Text Control?

19 views (last 30 days)
Is there a way to force a line feed or newline within text on a static text control in a Simulink mask?
I tried the typical \n \\n \n\r \newline chr(10) uint8(10) chr(13) uint8(13), etc. Nothing worked. The text was always printed literally.
I tried for days to look for help and documentation, but came up with nothing.
Is there an escape sequence that will work?

Answers (2)

Nicolas B.
Nicolas B. on 12 Aug 2019
Edited: Nicolas B. on 12 Aug 2019
Hey Jerry,
I just experienced the same issue as you. I found no solution to add a space in a Text Display box through the Mask Editor.
However, I have found a workaround! Let's imagine you have a textbox with the name myTextBox in the mask and you want to write :
line 1
line 2
Then, use select the block in Simulink (to be able to use gcb) and then, in the MATLAB console:
% get the handle of the mask
maskObj = Simulink.Mask.get(gcb);
% get the handle of the Text box
tbObj = maskObj.getDialogControl('myTextBox');
% set the Prompt value
tbObj.Prompt = ['line 1', ...
10, ... % 10 must be a numerical value to be ASCII(10)
'line 2'];
% now, check your mask.It should have worked
Hope it helps.

Jean-Guilhem Dalissier
Jean-Guilhem Dalissier on 19 Jul 2022
A solution is to use the HTML break tag:
line 1<br>line 2
More generally the Prompt field of a control seems to accept HTML so more sophisticated formatting may be acheived, for example:
Some text formatting in a list:<ol><li>Normal <b>bold</b> <i>italic</i> <span style="font-family:'Courier New';color:red;font-size:10px">Small_Red_CourierNew</span></li> <li>P = R<sub>1</sub>.I<sup>2</sup></li> <li>U1 &#62; U2 </li> </ol>

Categories

Find more on Author Block Masks 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!