Im following the simple tutorial on youtube to get a feedback response during text input into a .newTextField and I cannot for the life of me get it to work at all. If im being a total idiot feel free to tell me along with the reason it isnt working…
The Feedback response is the part that isnt working. If I put print(“hello”) in the first line of the function before the if statement i get the hello in the simulator terminal, but none of the if statement changes the local lblFeedback so where it should be responding to the event.phases in the function there is no change.
TUTORIAL BEING FOLLOWED:
https://www.youtube.com/watch?v=0z7BVlOjHro
CODE:
local color = require(“plugin.awcolor”)
_W = display.pixelWidth
_H = display.pixelHeight
local background = display.newRect(0, 0, _W, _H)
background:setFillColor(color.fromRGB(247, 155, 51))
local lblFirstName = display.newText(“First Name:”, 100, 80, native.systemFont, 14)
local txtFirstName = native.newTextField(160, 100, 200, 20)
txtFirstName.size = 18
local lblFeedback = display.newText("", 80, 200, native.systemFont, 16)
function txtFirstName:userInput(e)
if (e.phase == “began”) then
e.target.text = ‘’
lblFeedback = “waiting”
elseif (e.phase == “submitted” or e.phase == “ended”) then
lblFeedback = "Welcome " … e.target.text
elseif (e.phase == “editing”) then
lblFeedback = e.startPosition
end
end
txtFirstName:addEventListener(“userInput”, txtFirstName)
function background:tap (e)
native.setKeyboardFocus(nil)
end
background:addEventListener(“tap”, background)