Hello, currently I am facing a problem of getting the user input from a textfield to be placed into a string variable once the user finishes typing. My end goal is to take the user input and compare it to a different string later.
My current code for user input:
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
--print("Here is the final text: " ,text)
– Create text field
defaultField = native.newTextField( display.contentCenterX, 300, 190, 30 )
defaultField:addEventListener( “userInput”, textListener )