对象:getSelection()

类型 函数
对象 文本框
native.*
返回值
修订版 2024.3703 版
关键词 getSelection
另请参阅 native.newTextBox()

概览

返回光标的第一个和最后一个位置。

语法

object:getSelection()

示例

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