object:getSelection()

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

概述

返回光标的起始和结束位置。

语法

object:getSelection()

示例

local textField = native.newTextField( 160, 240, 280, 40 )

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

local start, finish = textField: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