Type String Event userInput Revision Release 2024.3703 Keywords userInput, text See also event.target native.newTextBox() native.newTextField()
This property is only available during the "editing"
phase of userInput events. On a phase of "submitted"
or "ended"
, use event.target.text
to access the input object's text contents.
local defaultField local function textListener( event ) if ( event.phase == "began" ) then -- User begins editing "defaultField" elseif ( event.phase == "ended" or event.phase == "submitted" ) then -- Output resulting text from "defaultField" print( event.target.text ) elseif ( event.phase == "editing" ) then print( event.newCharacters ) print( event.oldText ) print( event.startPosition ) print( event.text ) end end -- Create text field defaultField = native.newTextField( 150, 150, 180, 30 ) defaultField:addEventListener( "userInput", textListener )