[英]Android Corona sdk textInput event listener for new text
我嘗試創建事件偵聽器(未檢測到輸入到textInput中的任何新文本)沒有成功。 每當文本僅更改一個字符時,我希望偵聽器調用另一個函數。 任何建議表示贊賞。
嘗試這個:
local function fctTextFieldListener(oEvent)
if "began" == oEvent.phase then
-- First edition
elseif "editing" == oEvent.phase then
-- During edition
elseif "submitted" == oEvent.phase then
-- End of edition
end
end
local oTextField = native.newTextField( nX, nY, nWidth, nHeight)
oTextField:addEventListener( 'userInput', fctTextFieldListener )
您可以使用oTextField.text訪問oTextField文本:)在這種情況下,您需要在'began'事件(如果僅在第一版中)或在其他版本中的'editing'事件中調用函數。
干杯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.