native.newTextField

I am trying to make textfields/keyboard interaction very similar to Apple apps. So far so good after being able to remove the background.

One very important feature would be to access the Y position of the keyboard as it slides out. That way I can have objects move in tandem with it very nicely. [import]uid: 40116 topic_id: 24285 reply_id: 110581[/import]

I also have had some problems with text fields, it seems for the retina devices the x, y, w and h values must be divided by 2 for them to display correctly. They look wrong in the corona sim but on the xcode one and the devices they are correct.

Is there no way to make the qwerty keyboard default to number? The project I am working on involves inputting floating point numbers into the text fields but it always defaults to text input which is a real pain!! [import]uid: 148866 topic_id: 24285 reply_id: 111983[/import]

Is it not possible to remove the border?
[import]uid: 38237 topic_id: 24285 reply_id: 116124[/import]

On my phone using corona build 2012.840 I have tried using inputType = “number” and inputType = “url” and it has no effect on the keyboard type.

I am particularly after the input type that has the ‘Done’ button bottom right to close the keyboard, rather than having to create my own interface element to do this. [import]uid: 118305 topic_id: 24285 reply_id: 124298[/import]

The keyboard types do work. Look at the NativeKeyboard2 sample app in Corona. It shows all the keyboard types.

You set the keyboard by using:

object.inputType = "number"

On my phone using corona build 2012.840 I have tried using inputType = “number” and inputType = “url” and it has no effect on the keyboard type.

I am particularly after the input type that has the ‘Done’ button bottom right to close the keyboard, rather than having to create my own interface element to do this. [import]uid: 118305 topic_id: 24285 reply_id: 124298[/import]

The keyboard types do work. Look at the NativeKeyboard2 sample app in Corona. It shows all the keyboard types.

You set the keyboard by using:

object.inputType = "number"

I’m having difficulty adjusting a text field’s position on screen after it is created. I see the docs say that text fields are not affected by groups, but suggests you can still alter their properties directly.

[text]Also, they do not inherit display group properties like isVisible, x, y and alpha. If you need to set display properties on native objects, apply them to the objects directly.[/text]

I’m attempting to shift the text field up on screen by the same amount that I shift my entire display to make room for the keyboard when the text field is activated. All the Corona display objects move (as expected) but I can never get the native text field to shift position. Here’s the code I currently have:

[lua]-- height of keyboard on non-retina iPhone
local keyboardHeight = 216

–Textfield listener
local function textListener( event )
if event.phase == “began” then
– user begins editing textField, shift screen and text field up
display.getCurrentStage().y = -keyboardHeight
defaultField.y = 690 + defaultField.contentHeight/2 - keyboardHeight
elseif event.phase == “ended” or event.phase == “submitted” then
– remove keyboard and shift screen and text field down to default position
native.setKeyboardFocus( nil )
display.getCurrentStage().y = 0
defaultField.y = 690 + defaultField.contentHeight/2
end
end

– Create our Text Field
defaultField = native.newTextField( (display.contentWidth - 580)/2, 690, 580, 100 )
defaultField:addEventListener( “userInput”, textListener )[/lua]

With this code, the display stage correctly shifts up and down, but the [lua]defaultField[/lua] textField never moves. I’ve also tried using [lua]displayObject:translate(x, y)[/lua] instead of modifying the [lua]y[/lua] component directly, but the result is the same.

Anyone had success moving a native UI after it is created? [import]uid: 178289 topic_id: 24285 reply_id: 124862[/import]

I’m having difficulty adjusting a text field’s position on screen after it is created. I see the docs say that text fields are not affected by groups, but suggests you can still alter their properties directly.

[text]Also, they do not inherit display group properties like isVisible, x, y and alpha. If you need to set display properties on native objects, apply them to the objects directly.[/text]

I’m attempting to shift the text field up on screen by the same amount that I shift my entire display to make room for the keyboard when the text field is activated. All the Corona display objects move (as expected) but I can never get the native text field to shift position. Here’s the code I currently have:

[lua]-- height of keyboard on non-retina iPhone
local keyboardHeight = 216

–Textfield listener
local function textListener( event )
if event.phase == “began” then
– user begins editing textField, shift screen and text field up
display.getCurrentStage().y = -keyboardHeight
defaultField.y = 690 + defaultField.contentHeight/2 - keyboardHeight
elseif event.phase == “ended” or event.phase == “submitted” then
– remove keyboard and shift screen and text field down to default position
native.setKeyboardFocus( nil )
display.getCurrentStage().y = 0
defaultField.y = 690 + defaultField.contentHeight/2
end
end

– Create our Text Field
defaultField = native.newTextField( (display.contentWidth - 580)/2, 690, 580, 100 )
defaultField:addEventListener( “userInput”, textListener )[/lua]

With this code, the display stage correctly shifts up and down, but the [lua]defaultField[/lua] textField never moves. I’ve also tried using [lua]displayObject:translate(x, y)[/lua] instead of modifying the [lua]y[/lua] component directly, but the result is the same.

Anyone had success moving a native UI after it is created? [import]uid: 178289 topic_id: 24285 reply_id: 124862[/import]

@jared.sheets

I am having simliar problems. My textfield does move but the first time it gets positioned wrong. I have no clue whats going on here but someone maybe?

Joakim [import]uid: 81188 topic_id: 24285 reply_id: 126783[/import]

@jared.sheets

I am having simliar problems. My textfield does move but the first time it gets positioned wrong. I have no clue whats going on here but someone maybe?

Joakim [import]uid: 81188 topic_id: 24285 reply_id: 126783[/import]

Wondering if you will be making this available to Windows users in the near future? At work I use a Mac, but when I’m working from home I can’t do development because I have a Windows machine. Our app requires a login (using the text fields) to enter the app and I am currently not able to get past the login page in the simulator because the text fields do not render.

“Supported on operating systems and platforms for build numbers shown:
Mac OS X:Build 2011.679
Windows: – iOS: Corona SDK 2.0
Android: Corona SDK 2.0” [import]uid: 140942 topic_id: 24285 reply_id: 133561[/import]

@jared.sheets yes, you can move them. Something like this works for me:

local function slideFormUp()  
 transition.to(formGroup, {time=500,y=formGroup.y - 70})  
 transition.to(usernameField, {time=500,y=usernameField.y - 70})  
 transition.to(passwordField, {time=500,y=passwordField.y - 70})  
end  

I don’t see anything obvious in your code that would prevent it from working.

@Kirei, I’ll ask for an update on this.

Rob
[import]uid: 199310 topic_id: 24285 reply_id: 133599[/import]

@Kirie - had this same issue at one point, so used a test on my login screen that checked for this:

local isSimulator = "simulator" == system.getInfo("environment")  
  
 if( isSimulator == true ) then   
 loginName = "myAccount"  
 loginPassword = "myPassword"  
 end  

@hokieDev - There’s no built in way to do it, unfortunately… But via the textfield input handler, you can do it manually.

In your case, the easiest way overall might just be letting them type 123456789, but check the value of the number when they enter it, and limiting it to 123456after they hit enter.

I say that, because the manual way is kind of verbose (given the event driven nature of the whole thing)…

To limit the number of characters they type, in your keyboard handler function, you’ll first need to detect when they have typed as many chars as you want to limit them to (you’ll probably want to vary that for different input fields)…

 if( event.phase == "editing" ) then  
 if( string.len(event.text) \> maxEditLength ) then  
 -- We've gone past our limit of chars to enter....  
 -- now we need even more code to shave off the extra character that this event  
 -- has already stuck at the end of the event.text buffer...  
 end  
 end  

I would hope there’s something in the code exchange by now for quick, functional text entry to plug in to apps… Anyone checked in there lately? [import]uid: 79933 topic_id: 24285 reply_id: 133604[/import]

Wondering if you will be making this available to Windows users in the near future? At work I use a Mac, but when I’m working from home I can’t do development because I have a Windows machine. Our app requires a login (using the text fields) to enter the app and I am currently not able to get past the login page in the simulator because the text fields do not render.

“Supported on operating systems and platforms for build numbers shown:
Mac OS X:Build 2011.679
Windows: – iOS: Corona SDK 2.0
Android: Corona SDK 2.0” [import]uid: 140942 topic_id: 24285 reply_id: 133561[/import]

@jared.sheets yes, you can move them. Something like this works for me:

local function slideFormUp()  
 transition.to(formGroup, {time=500,y=formGroup.y - 70})  
 transition.to(usernameField, {time=500,y=usernameField.y - 70})  
 transition.to(passwordField, {time=500,y=passwordField.y - 70})  
end  

I don’t see anything obvious in your code that would prevent it from working.

@Kirei, I’ll ask for an update on this.

Rob
[import]uid: 199310 topic_id: 24285 reply_id: 133599[/import]

@Kirie - had this same issue at one point, so used a test on my login screen that checked for this:

local isSimulator = "simulator" == system.getInfo("environment")  
  
 if( isSimulator == true ) then   
 loginName = "myAccount"  
 loginPassword = "myPassword"  
 end  

@hokieDev - There’s no built in way to do it, unfortunately… But via the textfield input handler, you can do it manually.

In your case, the easiest way overall might just be letting them type 123456789, but check the value of the number when they enter it, and limiting it to 123456after they hit enter.

I say that, because the manual way is kind of verbose (given the event driven nature of the whole thing)…

To limit the number of characters they type, in your keyboard handler function, you’ll first need to detect when they have typed as many chars as you want to limit them to (you’ll probably want to vary that for different input fields)…

 if( event.phase == "editing" ) then  
 if( string.len(event.text) \> maxEditLength ) then  
 -- We've gone past our limit of chars to enter....  
 -- now we need even more code to shave off the extra character that this event  
 -- has already stuck at the end of the event.text buffer...  
 end  
 end  

I would hope there’s something in the code exchange by now for quick, functional text entry to plug in to apps… Anyone checked in there lately? [import]uid: 79933 topic_id: 24285 reply_id: 133604[/import]

Thanks so much mpappas! I will give that a try. [import]uid: 140942 topic_id: 24285 reply_id: 134200[/import]

Thanks so much mpappas! I will give that a try. [import]uid: 140942 topic_id: 24285 reply_id: 134200[/import]

I have to say that the keyboard input issue is very disappointing and will probably mean trying something else for developing cross-platform mobile applications. Everything was going great until this issue came up. I’m not particularly crazy about Lua for business apps (untyped variables just seem like a bad idea) but I can get around that with careful coding. It’s not truly object-oriented but then, nothing was when I started programming.

The lack of support for real text inputs, though and the length of time the issue seems to have been ignored (people have been asking for support on the Windows simulator for at least 1 year) are making me question the sanity of continuing down this path.

The Corona developers seem to be interested in pushing Corona as a viable option for business applications. This page (http://www.coronalabs.com/products/corona-sdk/, for instance, states:

From games to eBooks to business apps, Corona is unmatched in giving mobile app developers the ability to develop high quality content at record speeds.

Where is the actual evidence of any intention to support that claim? How is it that Adobe AIR, Titanium and even HTML5/PhoneGap manage to have text input boxes but Corona does not?

Sorry for the long rant but I thought I had finally found a platform worth committing myself to until just discovering this issue. More research is in order but it’s certainly not looking good. [import]uid: 156068 topic_id: 24285 reply_id: 135823[/import]