ctrlSetStructuredText: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|Game version=" to "|Game version= |gr1= GUI Control |GROUP1= ")
m (Some wiki formatting)
 
(47 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma |Game name=
|game1= arma1
|version1= 1.00


|1.00|Game version=
|game2= arma2
|version2= 1.00


|gr1= GUI Control |GROUP1=
|game3= arma2oa
|version3= 1.50


|game4= tkoh
|version4= 1.00


|game5= arma3
|version5= 0.50


|gr1= GUI Control |=GROUP1
|gr1= GUI Control
____________________________________________________________________________________________


| Set the [[Structured Text]] which will be displayed in [[DialogControls-Text#CT_STRUCTURED_TEXT.3D13|structured text control]]. |DESCRIPTION=
|gr2= Structured Text


|pr= Using this command will modify the provided ''structuredText'' - a way to circumvent this issue is to [[parseText]] in-line. See [[#Notes|Notes]]. |Problems=
|descr= Set the [[Structured Text]] which will be displayed in [[DialogControls-Text#CT_STRUCTURED_TEXT.3D13|structured text control]].
____________________________________________________________________________________________


| control [[ctrlSetStructuredText]] structuredText |SYNTAX=
|pr= Using this command will modify the provided ''structuredText'' - a way to circumvent this issue is to [[parseText]] in-line. See [[#Notes|Notes]].


|p1= control: [[Control]] |PARAMETER1=
|s1= control [[ctrlSetStructuredText]] structuredText


|p2= structuredText: [[Structured Text]] |PARAMETER2=
|p1= control: [[Control]]


| [[Nothing]] |RETURNVALUE=
|p2= structuredText: [[Structured Text]]
____________________________________________________________________________________________
 
|x1= <code>_control [[ctrlSetStructuredText]] [[parseText]] "First line<img image<nowiki>=</nowiki>data\isniper.paa /><nowiki><br /></nowiki>Second line"</code> |EXAMPLE1=
|x2= To adjust text vertically, add extra line above with blank space (&amp;#160;) and set its size accordingly:<code>[[with]] [[uiNamespace]] [[do]] {
button = [[findDisplay]] 46 [[ctrlCreate]] ["RscShortcutButton", -1];
button [[ctrlSetPosition]] [0,0,0.3,0.1];
button [[ctrlCommit]] 0;
button [[ctrlSetStructuredText]] [[parseText]]
"<t size='0.5'>&amp;#160;</t><nowiki><br/></nowiki><t size='1' align='center'>Button Text&amp;#160;&amp;#160;</t>";
};</code> |EXAMPLE2=


|x3= There is a bug with <tt>valign</tt> that requires adding 1 extra trailing space per line to the displayed text in order to keep it centered horizontally:
|r1= [[Nothing]]
<code>[[disableSerialization]];
[[private]] _ctrl = [[findDisplay]] 46 [[ctrlCreate]] ["RscStructuredText", -1];
_ctrl [[ctrlSetPosition]] [0, 0, 0.5, 0.5];
_ctrl [[ctrlSetBackgroundColor]] [0, 0, 0, 1];
_ctrl [[ctrlCommit]] 0;
[[private]] _lineHeight = [[getNumber]] ([[configFile]] >> "RscStructuredText" >> "size");
[[private]] _linesTotal = ([[ctrlPosition]] _ctrl [[select]] 2) / _lineHeight;
[[private]] _trailingSpace = "";
[[for]] "_i" [[from]] 1 [[to]] _linesTotal [[do]] { _trailingSpace = _trailingSpace + " " };
_ctrl [[ctrlSetStructuredText]] [[parseText]] [[format]] ["<t size='%1'><t size='1' align='center' valign='middle'>%2%3</t> </t>", _linesTotal, "------ Centered Text ------", _trailingSpace];</code>|EXAMPLE3=
____________________________________________________________________________________________


| [[Structured Text]], [[composeText]], [[parseText]], [[text]] |SEEALSO=
|x1= <sqf>_control ctrlSetStructuredText parseText "First line<img image=data\isniper.paa /><br />Second line"</sqf>
}}
 
|x2= To adjust text vertically, add extra line above with blank space (&amp;#160;) and set its size accordingly:
<sqf>
with uiNamespace do {
button = findDisplay 46 ctrlCreate ["RscShortcutButton", -1];
button ctrlSetPosition [0,0,0.3,0.1];
button ctrlCommit 0;
button ctrlSetStructuredText parseText
"<t size='0.5'>&#160;</t><br/><t size='1' align='center'>Button Text&#160;&#160;</t>";
};
</sqf>


<h3 style="display:none">Notes</h3>
|x3= There is a bug with {{hl|valign}} that requires adding 1 extra trailing space per line to the displayed text in order to keep it centered horizontally:
<sqf>
disableSerialization;
private _ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1];
_ctrl ctrlSetPosition [0, 0, 0.5, 0.5];
_ctrl ctrlSetBackgroundColor [0, 0, 0, 1];
_ctrl ctrlCommit 0;
private _lineHeight = getNumber (configFile >> "RscStructuredText" >> "size");
private _linesTotal = (ctrlPosition _ctrl select 2) / _lineHeight;
private _trailingSpace = "";
for "_i" from 1 to _linesTotal do { _trailingSpace = _trailingSpace + " " };
_ctrl ctrlSetStructuredText parseText format ["<t size='%1'><t size='1' align='center' valign='middle'>%2%3</t> </t>", _linesTotal, "------ Centered Text ------", _trailingSpace];
</sqf>


<dl class="command_description">
|seealso= [[Structured Text]] [[composeText]] [[parseText]] [[text]]
}}


<dd class="notedate">Posted on March 20, 2020 - 19:48 (UTC)</dd>
{{Note
<dt class="note">[[User:Dscha|Dscha]]</dt>
|user= Dscha
<dd class="note">
|timestamp= 20200320194800
When using [[parseText]] on an RscStructuredText control, with '''custom Attributes''' set (extra config Class), it needs to be in the same line as [[ctrlSetStructuredText]]: <br>
|text= When using [[parseText]] on an RscStructuredText control, with '''custom Attributes''' set (extra config Class), it needs to be in the same line as [[ctrlSetStructuredText]]:
<code>_text = "abc";
<sqf>
_ctrl [[ctrlSetStructuredText]] [[parseText]] _text;
_text = "abc";
</code><br>
_ctrl ctrlSetStructuredText parseText _text;
</sqf><br>
The following Code would use '''none''' of the custom Attributes of the selected Control, instead it falls back to Standard Values (Font, Size, Color, Align, etc)
The following Code would use '''none''' of the custom Attributes of the selected Control, instead it falls back to Standard Values (Font, Size, Color, Align, etc)
<code>_text = [[parseText]] "abc";
<sqf>
_ctrl [[ctrlSetStructuredText]] _text;
_text = parseText "abc";
</code>
_ctrl ctrlSetStructuredText _text;
</dd>
</sqf>
 
}}
</dl>
 
<h3 style="display:none">Bottom Section</h3>
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Armed Assault|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 12:32, 13 May 2022

Hover & click on the images for description

Description

Description:
Set the Structured Text which will be displayed in structured text control.
Problems:
Using this command will modify the provided structuredText - a way to circumvent this issue is to parseText in-line. See Notes.
Groups:
GUI ControlStructured Text

Syntax

Syntax:
control ctrlSetStructuredText structuredText
Parameters:
control: Control
structuredText: Structured Text
Return Value:
Nothing

Examples

Example 1:
_control ctrlSetStructuredText parseText "First line<img image=data\isniper.paa /><br />Second line"
Example 2:
To adjust text vertically, add extra line above with blank space (&#160;) and set its size accordingly:
with uiNamespace do { button = findDisplay 46 ctrlCreate ["RscShortcutButton", -1]; button ctrlSetPosition [0,0,0.3,0.1]; button ctrlCommit 0; button ctrlSetStructuredText parseText "<t size='0.5'>&#160;</t><br/><t size='1' align='center'>Button Text&#160;&#160;</t>"; };
Example 3:
There is a bug with valign that requires adding 1 extra trailing space per line to the displayed text in order to keep it centered horizontally:
disableSerialization; private _ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1]; _ctrl ctrlSetPosition [0, 0, 0.5, 0.5]; _ctrl ctrlSetBackgroundColor [0, 0, 0, 1]; _ctrl ctrlCommit 0; private _lineHeight = getNumber (configFile >> "RscStructuredText" >> "size"); private _linesTotal = (ctrlPosition _ctrl select 2) / _lineHeight; private _trailingSpace = ""; for "_i" from 1 to _linesTotal do { _trailingSpace = _trailingSpace + " " }; _ctrl ctrlSetStructuredText parseText format ["<t size='%1'><t size='1' align='center' valign='middle'>%2%3</t> </t>", _linesTotal, "------ Centered Text ------", _trailingSpace];

Additional Information

See also:
Structured Text composeText parseText text

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Dscha - c
Posted on Mar 20, 2020 - 19:48 (UTC)
When using parseText on an RscStructuredText control, with custom Attributes set (extra config Class), it needs to be in the same line as ctrlSetStructuredText:
_text = "abc"; _ctrl ctrlSetStructuredText parseText _text;

The following Code would use none of the custom Attributes of the selected Control, instead it falls back to Standard Values (Font, Size, Color, Align, etc)
_text = parseText "abc"; _ctrl ctrlSetStructuredText _text;