ctrlTextWidth: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Undo revision 169361 by R3vo (talk))
Tag: Undo
mNo edit summary
Line 33: Line 33:
}}
}}


<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Arma 3: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Arma 3: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
<!-- CONTINUE Notes -->
<!-- DISCONTINUE Notes -->
{{subst:Add new note/construct|
When working with multiline controls [[ctrlTextWidth]] or [[getTextWidth]] will not return a proper value since the text will be treated as one long line.
Solution:
[[disableSerialization]];
_display = [[findDisplay]] 313 [[createDisplay]] "RscDisplayEmpty";
_edit = _display [[ctrlCreate]] ["RscEditMulti", -1];
_edit [[ctrlSetPosition]] [0,0,1,1];
_edit [[ctrlSetBackgroundColor]] [0,0,0,1];
_edit [[ctrlSetFont]] "EtelkaMonospacePro";
_edit [[ctrlSetFontHeight]] 0.03;
_edit [[ctrlCommit]] 0;
[[private]] _longestLineWidth = 0;
[[private]] _exampleString = "abcdefghijklmnopqrstuvxyz0134567890";
[[private]] _text = "";
[[for]] "_lines" [[from]] 1 [[to]] 400 [[do]]
{
    _lineText = _exampleString [[select]] <nowiki>[</nowiki>[[round]] [[random]] 35];
    _longestLineWidth = _longestLineWidth [[max]] (_lineText [[getTextWidth]] ["EtelkaMonospacePro", 0.03]);
    _text = _text [[+]] _lineText [[+]] [[endl]];
};
_edit [[ctrlSetText]] _text;
_edit [[ctrlSetPositionW]] (_longestLineWidth [[+]] 2 * 0.008);
_edit [[ctrlCommit]] 1;

Revision as of 23:09, 28 October 2020

Hover & click on the images for description

Description

Description:
Returns the width of the control text including left and right margins (0.008 each). Supported control types are:
For control independent text width estimate see getTextWidth
Groups:
GUI Control

Syntax

Syntax:
ctrlTextWidth control
Parameters:
control: Control
Return Value:
Number

Examples

Example 1:
_w = ctrlTextWidth _ctrl;

Additional Information

See also:
ctrlFontHeight getTextWidthctrlTextHeightctrlSetTextctrlTypeArma: GUI Configuration

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