ctrlSetTextSelection: Difference between revisions

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


| arma3dev |Game name=
|game1= arma3
|version1= 2.00


|1.99 |Game version=
|gr1= GUI Control


|gr1= GUI Control |GROUP1=
|descr=Selects {{hl|length}} characters of edit control from the {{hl|start}} position and places cursor at the end of selection.
{{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]


|p1= control: [[Control]]


||gr1= GUI Control|GROUP1=
|p2= start: [[Number]] - selection start position
____________________________________________________________________________________________


|Selects 'length' characters of edit control from the 'start' position and places cursor at the end of selection. To move cursor only, set 'length' to 0. |DESCRIPTION=
|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)
____________________________________________________________________________________________


| control [[ctrlSetTextSelection]] [start, length] |SYNTAX=
|r1= [[Nothing]]


|p1= control: [[Control]] |PARAMETER1=
|x1= <sqf>_control ctrlSetTextSelection [5, 10];</sqf>


|p2= [start, length]: [[Array]] |PARAMETER2=
|x2= <sqf>
|p3= start: [[Number]] - selection start position |PARAMETER3=
disableSerialization;
|p4= length: [[Number]] - length of characters to select (0 to only move the cursor) |PARAMETER4=
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;
</sqf>


| [[Nothing]] |RETURNVALUE=
|x3= Select text from right to left:
 
<sqf>_control ctrlSetTextSelection [5, -4];</sqf>
____________________________________________________________________________________________
 
|x1= <code>_control [[ctrlSetTextSelection]] [5, 10]</code>|EXAMPLE1=
 
|x2= <code>[[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;</code>|EXAMPLE2=
____________________________________________________________________________________________
 
| [[ctrlTextSelection]] [[ctrlSetText]]  |SEEALSO=


|seealso= [[ctrlTextSelection]] [[ctrlSetText]]
}}
}}
<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 Arma 3|{{uc:{{PAGENAME}}}}]]

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