类型 函数 对象 文本框 库 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