フィルターのクリア

Simulink Mask newline or line feed in Static Text Control?

19 ビュー (過去 30 日間)
Jerry Girard
Jerry Girard 2016 年 11 月 1 日
回答済み: Jean-Guilhem Dalissier 2022 年 7 月 19 日
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?

回答 (2 件)

Nicolas B.
Nicolas B. 2019 年 8 月 12 日
編集済み: Nicolas B. 2019 年 8 月 12 日
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 2022 年 7 月 19 日
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>

カテゴリ

Help Center および File ExchangeAuthor Block Masks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by