native.newTextField lose focus

HI, 

what I want to accomplish is when I create a native.newTextField set the isSecure option to false and the placeholder to “type your password”

and whenever a user start typing, change the textfield to isSecure = true, to have the * symbols. 

with my approach I have the problem that my textfield lose focus after the first letter.

here is my code:

local function fieldHandler( event ) if ( "began" == event.phase ) then -- This is the "keyboard has appeared" event -- In some cases you may want to adjust the interface when the keyboard appears. elseif ( "ended" == event.phase ) then -- This event is called when the user stops editing a field: for example, when they touch a different field if(event.target.id == "password" and event.target.text == "")then event.target.isSecure = false passwordField.placeholder = "type your password" end elseif ( "editing" == event.phase ) then if(event.target.id == "password" and string.len(event.target.text) \>0 ) then event.target.isSecure = true --native.setKeyboardFocus( event.target ) end elseif ( "submitted" == event.phase ) then -- Hide keyboard native.setKeyboardFocus( nil ) end end

–scene:show

–Did

 local passwordField = native.newTextField( \_CX - fieldWidth/2, passwordFieldBg.y, fieldWidth, 40 ) passwordField.id = "password" passwordField:addEventListener( "userInput", fieldHandler ) group:insert( passwordField) passwordField.hasBackground = false passwordField.anchorX = 0 passwordField.placeholder = "type your password" passwordField.autocorrectionType = "UITextAutocorrectionTypeNo" passwordField.isSecure = false passwordField.font = native.newFont( gM.fontDin ) passwordField:resizeFontToFitHeight()

please help me to solve this, or another approach that I could use.

thanks,

Version 2016.2883 (2016.5.17) 

I thought Corona’s forum is the best. But unfortunately it’s not because of how slow their reply and sometimes they don’t. I ask about something but until now, no reply same with you.

Hi @cgpiao1. We do have a great community but sometimes posts get missed. If the community member who has the ability to answer the question doesn’t see it, the post can get buried under a bunch of new posts. Because of this we allow you to bump your post as long as 24 hours has passed since you asked. Simply go to the post and type in “bump” or “Can any one answer this?” so the post rises to the top of the stack.

Also you should consider if your question was asked in a way that encourages people to try and help. Forum regular @roaminggamer made a great post on what makes a great post that encourages responses.

https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/

The question above was pretty straight forward so it likely just got missed. 

I do have a question?.. Are you the original poster just using a different email? Or are you having the same problem?

Thanks

Rob

I thought Corona’s forum is the best. But unfortunately it’s not because of how slow their reply and sometimes they don’t. I ask about something but until now, no reply same with you.

Hi @cgpiao1. We do have a great community but sometimes posts get missed. If the community member who has the ability to answer the question doesn’t see it, the post can get buried under a bunch of new posts. Because of this we allow you to bump your post as long as 24 hours has passed since you asked. Simply go to the post and type in “bump” or “Can any one answer this?” so the post rises to the top of the stack.

Also you should consider if your question was asked in a way that encourages people to try and help. Forum regular @roaminggamer made a great post on what makes a great post that encourages responses.

https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/

The question above was pretty straight forward so it likely just got missed. 

I do have a question?.. Are you the original poster just using a different email? Or are you having the same problem?

Thanks

Rob