User Login Form

local defaultField -- TextField Listener local function fieldHandler( getObj ) -- Use Lua closure in order to access the TextField object return function( event ) print( "TextField Object is: " .. tostring( getObj() ) ) if ( "began" == event.phase ) then print("Began") -- This is the "keyboard has appeared" event elseif ( "ended" == event.phase ) then print("ended") -- This event is called when the user stops editing a field: -- for example, when they touch a different field or keyboard focus goes away print( "Text entered = " .. tostring( getObj().text ) ) -- display the text entered elseif ( "submitted" == event.phase ) then print("Submitted") -- This event occurs when the user presses the "return" key -- (if available) on the onscreen keyboard -- Hide keyboard native.setKeyboardFocus( nil ) end end -- "return function()" end text = display.newText("User Login", 10,10, native.systemFont, 22) text:setTextColor(205,201,201) text2 = display.newText("Username: ",10,30, native.systemFont, 22) text2:setTextColor(205,201,201) text3 = display.newText("Email: ",10,80, native.systemFont, 22) text3:setTextColor(205,201,201) -- Create our Text Field defaultField = native.newTextField( 150, 30, 200, 40 ) local function defaultHandler( event ) fieldHandler( function() return defaultField end ) -- passes the text field object end defaultField:addEventListener( "userInput", defaultHandler ) defaultField2 = native.newTextField( 150, 80, 200, 40 ) defaultField2.userInput2 = textListener defaultField2:addEventListener( "userInput2", defaultField2 )  

I am trying to create a form for a user to login to Corona Cloud or to create a new account. This is my first time using native.newTextField and I am struggling a bit. Here is the bit of code I have so far, I am still trying to wrap my head around it. This piece of code which I got from the Corona Docs: API is supposed to print to the console what I have input in the textfield, but I am getting nothing. Can someone point me in the right direction and maybe give me some pointers for the next step of verifying a user or creating a new one.

Thanks.

Did you test this in the device?

In the simulator the native.newTextField is not suppose to work.

Ema
 

Yes I was testing on device, I know they don’t work on simulator. I think I am just try using the gameNetwork dashboard to avoid all the hassle of creating my own forms

Did you test this in the device?

In the simulator the native.newTextField is not suppose to work.

Ema
 

Yes I was testing on device, I know they don’t work on simulator. I think I am just try using the gameNetwork dashboard to avoid all the hassle of creating my own forms