ctrlSetStructuredText: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 32: | Line 32: | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
|x1= < | |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 (&#160;) and set its size accordingly: | |x2= To adjust text vertically, add extra line above with blank space (&#160;) and set its size accordingly: | ||
< | <sqf> | ||
button = | with uiNamespace do { | ||
button | button = findDisplay 46 ctrlCreate ["RscShortcutButton", -1]; | ||
button | button ctrlSetPosition [0,0,0.3,0.1]; | ||
button | button ctrlCommit 0; | ||
"<t size='0.5'>& | button ctrlSetStructuredText parseText | ||
};</ | "<t size='0.5'> </t><br/><t size='1' align='center'>Button Text  </t>"; | ||
}; | |||
</sqf> | |||
|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: | |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; | |||
_ctrl | private _ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1]; | ||
_ctrl | _ctrl ctrlSetPosition [0, 0, 0.5, 0.5]; | ||
_ctrl | _ctrl ctrlSetBackgroundColor [0, 0, 0, 1]; | ||
_ctrl ctrlCommit 0; | |||
private _lineHeight = getNumber (configFile >> "RscStructuredText" >> "size"); | |||
private _linesTotal = (ctrlPosition _ctrl select 2) / _lineHeight; | |||
private _trailingSpace = ""; | |||
_ctrl | 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> | |||
|seealso= [[Structured Text]] [[composeText]] [[parseText]] [[text]] | |seealso= [[Structured Text]] [[composeText]] [[parseText]] [[text]] | ||
}} | }} | ||
{{Note | |||
|user= Dscha | |||
|timestamp= 20200320194800 | |||
|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]]: | |||
<sqf> | |||
_text = "abc"; | |||
When using [[parseText]] on an RscStructuredText control, with '''custom Attributes''' set (extra config Class), it needs to be in the same line as [[ctrlSetStructuredText]]: < | _ctrl ctrlSetStructuredText parseText _text; | ||
</sqf><br> | |||
_ctrl | |||
</ | |||
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) | ||
< | <sqf> | ||
_ctrl | _text = parseText "abc"; | ||
</ | _ctrl ctrlSetStructuredText _text; | ||
</sqf> | |||
}} | |||
Latest revision as of 12:32, 13 May 2022
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 ( ) 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'> </t><br/><t size='1' align='center'>Button Text  </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
- 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:
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)
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: GUI Control
- Command Group: Structured Text