Hi,
I want to give users the ability to enter their name. I am using the textfield option with the following example code
local name
local function textListener( event )
if event.phase == "editing" then
name=nil
print( event.text )
name=event.text
end
if event.phase == "submitted" then
print("This is the name:"..name)
end
end
-- Create our Text Field
defaultField = native.newTextField( 10, 30, 180, 30 )
defaultField:addEventListener( "userInput", textListener )
Is this the correct way?
Is there a better way to set the event.text to a variable.
If I don’t do it in the editing phase I get a nil value in the submitted. If I just use print (event.text)
Why I set it to nil first? That way I know it will be clear when I set the text to the variable. Cause i the editing phase it keeps updating as I type.
My option doesn’t seem the way to do this.
Thanks [import]uid: 100901 topic_id: 36960 reply_id: 336960[/import]