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