ctrlSetTextSelection: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *arma3 * * *\| *([0-2]\.[0-9]{2}) * " to "|game1= arma3 |version1= $1 ")
m (Some wiki formatting)
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
|gr1= GUI Control
|gr1= GUI Control


|descr=Selects <tt>length</tt> characters of edit control from the <tt>start</tt> position and places cursor at the end of selection.
|descr=Selects {{hl|length}} characters of edit control from the {{hl|start}} position and places cursor at the end of selection.
{{Feature | Informative | To move cursor only, set <tt>length</tt> to 0. To select text from right to left, use negative <tt>length</tt> (See [[ctrlTextSelection]] for more info)}}
{{Feature|informative|To only move the cursor, set ''length'' to 0. To select text from right to left, use negative ''length'' (See [[ctrlTextSelection]] for more info)}}


|s1= control [[ctrlSetTextSelection]] [start, length]
|s1= control [[ctrlSetTextSelection]] [start, length]


|p1= control: [[Control]]
|p1= control: [[Control]]


|p2= [start, length]: [[Array]]
|p2= start: [[Number]] - selection start position
|p3= start: [[Number]] - selection start position
 
|p4= length: [[Number]] - length of characters to select (0 to only move the cursor). Negative length will select text from right to left (see example 3)
|p3= length: [[Number]] - length of characters to select (0 to only move the cursor). Negative length will select text from right to left (see example 3)


|r1= [[Nothing]]
|r1= [[Nothing]]


|x1= <code>_control [[ctrlSetTextSelection]] [5, 10]</code>
|x1= <sqf>_control ctrlSetTextSelection [5, 10];</sqf>


|x2= <code>[[disableSerialization]];
|x2= <sqf>
[[private]] _ctrl = [[findDisplay]] 46 [[createDisplay]] "RscDisplayEmpty" [[ctrlCreate]] ["RscEditMulti", -1];  
disableSerialization;
_ctrl [[ctrlSetPosition]] [0,0,0.5,0.3];
private _ctrl = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscEditMulti", -1];
_ctrl [[ctrlCommit]] 0;  
_ctrl ctrlSetPosition [0,0,0.5,0.3];
_ctrl [[ctrlSetText]] "Hello World";  
_ctrl ctrlCommit 0;
_ctrl [[ctrlSetTextSelection]] [6, 5]; // selects World
_ctrl ctrlSetText "Hello World";
[[ctrlSetFocus]] _ctrl;</code>
_ctrl ctrlSetTextSelection [6, 5]; // selects World
ctrlSetFocus _ctrl;
</sqf>


|x3= Select text from right to left:<code>_control [[ctrlSetTextSelection]] [5, -4]</code>
|x3= Select text from right to left:
<sqf>_control ctrlSetTextSelection [5, -4];</sqf>


|seealso= [[ctrlTextSelection]] [[ctrlSetText]]
|seealso= [[ctrlTextSelection]] [[ctrlSetText]]
}}
}}

Latest revision as of 11:30, 4 May 2022

Hover & click on the images for description

Description

Description:
Selects length characters of edit control from the start position and places cursor at the end of selection.
To only move the cursor, set length to 0. To select text from right to left, use negative length (See ctrlTextSelection for more info)
Groups:
GUI Control

Syntax

Syntax:
control ctrlSetTextSelection [start, length]
Parameters:
control: Control
start: Number - selection start position
length: Number - length of characters to select (0 to only move the cursor). Negative length will select text from right to left (see example 3)
Return Value:
Nothing

Examples

Example 1:
_control ctrlSetTextSelection [5, 10];
Example 2:
disableSerialization; private _ctrl = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscEditMulti", -1]; _ctrl ctrlSetPosition [0,0,0.5,0.3]; _ctrl ctrlCommit 0; _ctrl ctrlSetText "Hello World"; _ctrl ctrlSetTextSelection [6, 5]; // selects World ctrlSetFocus _ctrl;
Example 3:
Select text from right to left:
_control ctrlSetTextSelection [5, -4];

Additional Information

See also:
ctrlTextSelection ctrlSetText

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