RESOLVED: Can't change textfield text in Android or Corona Simulator using Windows build

I tried this with release build 2393, as well as daily builds 2482 and 2484.  The problem happens on them all.
 
I developed my app on my Mac and it is working great in the Corona Simulator on Mac, as well as on iOS devices.
 
I moved the code over to my Windows machine to build for Android and I am running into a problem with textfields.
 
Here is the code:

[lua]if team1Textfield.text == “” then
print( “We need to set a default for player 1.” )
team1Textfield.text = “Player 1”
end

print( "First player name: " … team1Textfield.text )[/lua]

When I run the app in the Corona Simulator, looking in the Corona Simulator Output window, I see both print statements are firing, but team1Textfield.text remains with a value of an empty string (not nil, just no text).  It never gets changed.

I did the Android build and copied it to a device and the same thing happens there.

Why would this be happening?  What would cause the textfield to not allow its value to be changed in the  Windows version of Corona Simulator and thus, the Android builds?

This is driving me nuts.

Created a simple way to reproduce this, and logged it as a bug.
 
It is Case 36835.

https://dl.dropboxusercontent.com/u/37778165/hw_textfield.zip

Corona SDK does not support native.newTextField’s for Windows.  This is due to a Microsoft limitation where you can’t put native.newTextFields into an OpenGL canvas.  This is not something Corona Labs can fix as long as we use OpenGl.

Why don’t you build for Android from your Mac?

I’m sorry, Rob, but are you actually saying that you can’t use Windows to build an Android app with a native.newtextfield because they will not work according to how they are documented?

No.  I’m saying you cannot use native.newTextField() in the Windows simulator.  See “Gotchas” #1:

http://docs.coronalabs.com/api/library/native/newTextField.html

You can build for Android just fine and the textfields will work on Android devices just fine.  You just get placeholders in the Windows simulator.

But my other question was if you have a Mac, why are you using Windows? 

The reason I use Windows for the Android builds is because I had problems actually getting Corona to build an Android app on a Mac.

And as I explained above, I did build the app for Android and had the same problem.  Trying to change the textfield did not work.  I had not even tried in the Corona Simulator until I was trying to figure out what was happening.  My first steps were to build an Android APK and copy to a device and the problem occurred there. That’s when I discovered the issue in the Simulator.

So got a reply from Tom to my bug posting and I got this worked out.

I had missed the documented note – “Native text fields are only available in device builds, the Xcode Simulator, and in the Corona Mac Simulator.” – or actually had misinterpreted it.  Since I had seen other posts, like Rob’s, about the issues with the OpenGL canvas on Windows, I had thought that this was simply a rendering issue.  I had not taken it to mean that any of the textfield functionality – like the reading and setting of the .text property – also did not work in the Corona Simulator on Windows.

The fix was to add in a delay, which I had already tried, but only in the Corona Simulator, which obviously was its own issue.   :slight_smile:

From Tom:

What will not work is your print statement to print the text field text right after you set it. The text field is not updated until the next frame so you would need to add a delay before reading it back. This is a known Android issue and we need to document it.

timer.performWithDelay( 1,
    function()
        print(“team1Textfield.text value:” … team1Textfield.text)
    end )

I definitely think that some clearer documentation would definitely help here.

Thanks to Rob and Tom for their help.

Created a simple way to reproduce this, and logged it as a bug.
 
It is Case 36835.

https://dl.dropboxusercontent.com/u/37778165/hw_textfield.zip

Corona SDK does not support native.newTextField’s for Windows.  This is due to a Microsoft limitation where you can’t put native.newTextFields into an OpenGL canvas.  This is not something Corona Labs can fix as long as we use OpenGl.

Why don’t you build for Android from your Mac?

I’m sorry, Rob, but are you actually saying that you can’t use Windows to build an Android app with a native.newtextfield because they will not work according to how they are documented?

No.  I’m saying you cannot use native.newTextField() in the Windows simulator.  See “Gotchas” #1:

http://docs.coronalabs.com/api/library/native/newTextField.html

You can build for Android just fine and the textfields will work on Android devices just fine.  You just get placeholders in the Windows simulator.

But my other question was if you have a Mac, why are you using Windows? 

The reason I use Windows for the Android builds is because I had problems actually getting Corona to build an Android app on a Mac.

And as I explained above, I did build the app for Android and had the same problem.  Trying to change the textfield did not work.  I had not even tried in the Corona Simulator until I was trying to figure out what was happening.  My first steps were to build an Android APK and copy to a device and the problem occurred there. That’s when I discovered the issue in the Simulator.

So got a reply from Tom to my bug posting and I got this worked out.

I had missed the documented note – “Native text fields are only available in device builds, the Xcode Simulator, and in the Corona Mac Simulator.” – or actually had misinterpreted it.  Since I had seen other posts, like Rob’s, about the issues with the OpenGL canvas on Windows, I had thought that this was simply a rendering issue.  I had not taken it to mean that any of the textfield functionality – like the reading and setting of the .text property – also did not work in the Corona Simulator on Windows.

The fix was to add in a delay, which I had already tried, but only in the Corona Simulator, which obviously was its own issue.   :slight_smile:

From Tom:

What will not work is your print statement to print the text field text right after you set it. The text field is not updated until the next frame so you would need to add a delay before reading it back. This is a known Android issue and we need to document it.

timer.performWithDelay( 1,
    function()
        print(“team1Textfield.text value:” … team1Textfield.text)
    end )

I definitely think that some clearer documentation would definitely help here.

Thanks to Rob and Tom for their help.