ubaldo
ubaldo

Reputation: 41

corona problems with native.newtextfield

I am making a login page on a corona new game. There are two fields (username and password) and for both I have the same issue after loading the app on android mobile phones.

While inserting text I cannot see characters that appear pushed in the upper part of the textfield. As a result everything is not readable.

I used textbox hight = 60 and fontsize=20.

Nevertheless text align in the upper part and it is quite hard to understand what I am writing...

Any help?

Please find below the code:

  local function pswHandler( text2Field )

  return function( 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


    usrPsw=text2Field().text

elseif ( "editing" == event.phase ) then

elseif ( "submitted" == event.phase ) then
  -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard


  -- Hide keyboard
  native.setKeyboardFocus( nil )
end
end
end







function login()



infoBox=display.newImage("settings.png")
infoBox.x=W
infoBox.y=H-35

transition.from(infoBox,{time=0,xScale=0.5,yScale=0.6,transition=easing.cutExpo})

usrfield = native.newTextField( 390, 350, 500, 60 )
usrfield.font = native.newFont(native.systemFont, 20 )
usrfield.inputType = "text"
usrfield.hasBackground=true
usrfield:setTextColor(0,0,0,255)
usrfield:addEventListener( "userInput", usrHandler( function() return usrfield end ) ) 
usrUsr=usrfield.text

avv1=display.newText("Username: ",140,290,"RepriseStamp",30)
avv1.anchorX=0
avv1:setTextColor(1,1,0,255)

pswfield = native.newTextField( 390, 500, 500, 60 )
pswfield.font = native.newFont( native.systemFont, 20 )
pswfield.inputType = "text"
pswfield.hasBackground=true
pswfield:setTextColor(0,0,0,255)
pswfield:addEventListener( "userInput", pswHandler( function() return pswfield end ) ) 
pswfield.isSecure=true
usrPsw=pswfield.text

avv2=display.newText("Password: ",140,440,"RepriseStamp",30)
avv2.anchorX=0
avv2:setTextColor(1,1,0,255)

nl1=display.newText("New? Click ",400,300,"RepriseStamp",40)
nl1:setTextColor(1,1,1,255)
nl1.x=W-50
nl1.y=150


   local buttonOK1 = widget.newButton
{
   id = "buttonOK1",
   defaultFile = "buttonbn.png",
   label = "OK",
   labelColor = 
 { 
 default = { 0, 0, 0, 255 },
 },
 font = "RepriseStamp",
 fontSize = 30,
 emboss = true,
 onEvent = connetti,
 isEnabled=true
}

buttonOK1.x=490
buttonOK1.y=600

Upvotes: 0

Views: 243

Answers (1)

Rob Miracle
Rob Miracle

Reputation: 3063

Get a later daily build and give it a try. We optimized sizing text fields after the last public build.

Upvotes: 0

Related Questions