{"name":"ctrlTextSelection","operator":null,"title":"ctrlTextSelection","type":"command","url":"https://community.bistudio.com/wiki/ctrlTextSelection","revid":377654,"updated":"2026-01-02T09:02:02Z","groups":["GUI Control"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.00"}],"since":{"game":"arma3","name":"Arma 3","version":"2.00"},"arma3_since":"2.00","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Returns edit control text selection in format [start, length, selectedText].\n\n> [!NOTE]\n> *length* can be negative if text selection is made from right to left. Use abs with *length* or count with `selectedText` if string length is required. *start* always indicates at what position in text the selection is started. The cursor position will always be at the end of the selection. So if selection is made from right to left the cursor position will be at the left end of the selection. In order to find cursor position add *start* and *length* together (see #Example 3).","syntaxes":[{"syntax":"ctrlTextSelection control","since":null,"effect":null,"exec":null,"params":[{"name":"control","type":"Control","optional":false,"default":null,"description":null,"types":["Control"],"since":null,"text":"control: Control"}],"returns":{"type":"Array with [start, length, selectedText]","types":["Array"],"description":"start: Number - position in text selection started - length: Number - number of the highlighted characters (this number could be negative, see description) - selectedText: String - selected text","text":"Array with [start, length, selectedText]\n- start: Number - position in text selection started\n- length: Number - number of the highlighted characters (this number could be negative, see description)\n- selectedText: String - selected text"},"form":"unary","operator":null,"left":null,"right":{"text":"control","types":["Control"]}}],"examples":[{"text":"Selection is made from left to right:\n\n```sqf\nctrlTextSelection _control; //[0, 11, \"Hello World\"];\n```","code":["ctrlTextSelection _control; //[0, 11, \"Hello World\"];"]},{"text":"Selection is made from right to left:\n\n```sqf\nctrlTextSelection _control; //[11, -11, \"Hello World\"];\n```","code":["ctrlTextSelection _control; //[11, -11, \"Hello World\"];"]},{"text":"Find cursor position:\n\n```sqf\nctrlTextSelection _control params [\"_start\", \"_length\"];\nprivate _cursorPos = _start + _length;\n```","code":["ctrlTextSelection _control params [\"_start\", \"_length\"];\nprivate _cursorPos = _start + _length;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["ctrlSetTextSelection"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control","Introduced with Arma 3 version 2.00","Scripting Commands"]}