Type Function Object TextBox Library native.* Return value none Revision 2018.3434 Keywords setSelection See also native.newTextBox()
Sets the cursor position if the start and end positions are the same. Alternatively, sets a range of selected text if the start and end positions are different.
object:setSelection( startPosition, endPosition )
Number. The cursor position or the beginning of the selection area. To select the first character, this value should be
Number. The end of the selection area, if greater than
startPosition. The last character will be used if this number is greater than the length of the current string in the text box.
local textBox = native.newTextBox( 160, 240, 280, 140 ) textBox.text = "asdf" native.setKeyboardFocus( textBox ) textBox:setSelection( 1, 3 ) -- The characters "sd" will be selected textBox:setSelection( 1, 1 ) -- Cursor will be placed between "a" and "s"