object:getSelection()

Type Function
Object TextBox
Library native.*
Return value none
Revision Release 2024.3703
Keywords getSelection
See also native.newTextBox()

Overview

Returns the cursors first and last position.

Syntax

object:getSelection()

Example

local textBox = native.newTextBox( 160, 240, 280, 40 )

textBox.text = "asdf"
native.setKeyboardFocus( textBox )

local start, finish = textBox:getSelection()
-- if native cursor is placed after the "f" in the text, start and finish would return 4, 4
-- if native cursor is selecting the whole text, start and finish would return, 0, 4