iOS 7 Beta Build

I filed a bug report.  I just use the sample app you referenced and when I added code to print the value of the text field.   When I run it on a device and view the device console, I can see that it is 1 step behind.  

I built the sample in “SampleCode/Interface” called “NativeKeyboard” with build 1210, iOS 6.1 target, using XCode 5 GM installing to my iPhone 5 running iOS 7 GM and it works as expected.  I also installed one of my apps that uses keyboard input and it’s also working fine.

Hopefully engineering can find this bug for you.

The iO7 native.textField editing issue has been fixed and available in Daily Build 1209.

I am still having problems with the latest build.  Here is sample code you can use.  Please verify that this works for you.    This does not work for me on iPhone 5 with iOS 7.   For me, when I run this code on a device, the text on screen is always one character behind the text shown in the input box.    I have a label which is showing the contents of the text field and you should see on simulator that the label matches the text field, but on an iOS7 device, the label does not match the text field.

local defaultField, defaultLabel local function fieldHandler( textField ) 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 elseif ( "editing" == event.phase ) then defaultLabel.text = textField().text elseif ( "submitted" == event.phase ) then -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard print( textField().text ) -- Hide keyboard native.setKeyboardFocus( nil ) end end end defaultField = native.newTextField( 10, 30, 180, 40 ) defaultField.font = native.newFont( native.systemFontBold, 15 ) defaultField:addEventListener( "userInput", fieldHandler( function() return defaultField end ) ) ------------------------------------------- -- \*\*\* Add field labels \*\*\* ------------------------------------------- defaultLabel = display.newText( "Copy of text in text field", 50, 105, native.systemFont, 18 ) defaultLabel:setTextColor( 170, 170, 255, 255 )

textField().text has the right information in it when it’s submitted.  But I can see where this is an annoyance in particular for people who don’t use the native textfield on screen but are writing to their own display.newText().

Please file a bug report on it with this code.  You might want to include a use case as to why you can’t just grab the value in the submitted phase.

Rob

I reported this 16th august, case 25641.

  1. local function textListener( event )
  2.     
  3.     if event.phase == “editing” then
  4.         print("event.newCharacters ", event.newCharacters, “event.text”, event.text)
  5.     end
  6.     
  7. end
  8.  
  9. local defaultField = native.newTextField( 10, 30, 180, 30 )
  10. defaultField:addEventListener( “userInput”, textListener )
  11.  
  12. – Output Simulator + Android + iOS 6 when typing in ‘abc’
  13. – event.newCharacters     a    event.text    a
  14. – event.newCharacters     b    event.text    ab
  15. – event.newCharacters     c    event.text    abc
  16.  
  17. – Output iOS 7 Beta 3-5 when typing in ‘abc’
  18. – event.newCharacters     a    event.text
  19. – event.newCharacters     b    event.text    a
  20. – event.newCharacters     c    event.text    ab

I’m working with engineering on it.

Rob

I’m using the latest daily build (2013.1216).  iOS: Fixed an issue where the text from text fields and text boxes aren’t consistant with what is on the screen.

It looks like the problem is fixed for iOS 7 devices, but now the opposite is happening on non-iOS7 devices.   if I print event.text, I will see that the text on NON-ios7 devices is always 1 behind what is showing in the text field. 

Rob - Looks like the new fix doesn’t work and also introduces a crash.   Whenever I input data and then click next on the keyboard, the app crashes now.

local defaultField, defaultLabel local function fieldHandler( textField ) 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 elseif ( "editing" == event.phase ) then defaultLabel.text = textField().text elseif ( "submitted" == event.phase ) then -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard print( tostring(textField().text) ) -- Hide keyboard native.setKeyboardFocus( nil ) end end end defaultField = native.newTextField( 10, 30, 180, 40 ) defaultField.font = native.newFont( native.systemFontBold, 15 ) defaultField:addEventListener( "userInput", fieldHandler( function() return defaultField end ) ) ------------------------------------------- -- \*\*\* Add field labels \*\*\* ------------------------------------------- defaultLabel = display.newText( "Copy of text in text field", 50, 105, native.systemFont, 18 ) defaultLabel:setTextColor( 170, 170, 255, 255 )

I will alert the engineers.

Thanks.  Everything appears to be fixed with the latest build.

This is still an issue in 1259 (can’t use 1260 due to other bug with it). Here’s the output in the editing phases of the newTextField:

... in first editing event ... Jan 27 21:24:05 ... : event.oldText = aasdfa Jan 27 21:24:05 ... : event.startPosition = 4 Jan 27 21:24:05 ... : event.newCharacters = Q Jan 27 21:24:05 ... : event.text = aasdfaQ -- WRONG! screen correctly shows aasQdfa Jan 27 21:24:05 ... : self.nativeTextField.text = aasdfaQ -- WRONG! screen correctly shows aasQdfa ... in 2nd editing event ... Jan 27 21:24:32 ... : event.oldText = aasQdfa -- Okay, now this is right on the 2nd editing event Jan 27 21:24:32 ... : event.startPosition = 5 Jan 27 21:24:32 ... : event.newCharacters = Q Jan 27 21:24:32 ... : self.nativeTextField.text = aasQdfaQ -- WRONG again but screen aasQQdfa Jan 27 21:24:32 ... : event.text = aasQdfaQ -- WRONG again but screen aasQQdfa ... now, in "ended" event ... Jan 27 21:25:20 ... : event.target.text = aasQdfaQ -- STILL WRONG on exit.  

I have checked the daily build logs and seen only 1209 and 1216 that address newTextField issues. This is only an iOS 7 issue in my build 1259, but I’m going to have to work around it somehow.

More recent discussion on this problem can be found here:

http://forums.coronalabs.com/topic/41321-ios-native-text-field-incorrectly-inserting-characters-if-cursor-is-moved/

As of 22 Nov 2013: it’s supposedly fixed in G2, and thus far, those who haven’t ported to G2 are out of luck.

What is the bug in 1260 that’s holding you back?

Rob

Hi, Rob. The bug in 1260 is this:

http://forums.coronalabs.com/topic/41409-20131260-runtime-error-in-managerowlifecycle/

If you have to continue to use a Graphics 1.0 build, you might want to consider downloading the Widget library from GitHub.  This particular error is fixed in the library so you should be able to use 1260 or 1262 and get past this error.

Rob

I’ve managed to avoid using Github code thus far, but that’s not a bad idea. I’m hoping to have converted to G2 or compatibility mode by the next release.

This is still an issue in 1259 (can’t use 1260 due to other bug with it). Here’s the output in the editing phases of the newTextField:

... in first editing event ... Jan 27 21:24:05 ... : event.oldText = aasdfa Jan 27 21:24:05 ... : event.startPosition = 4 Jan 27 21:24:05 ... : event.newCharacters = Q Jan 27 21:24:05 ... : event.text = aasdfaQ -- WRONG! screen correctly shows aasQdfa Jan 27 21:24:05 ... : self.nativeTextField.text = aasdfaQ -- WRONG! screen correctly shows aasQdfa ... in 2nd editing event ... Jan 27 21:24:32 ... : event.oldText = aasQdfa -- Okay, now this is right on the 2nd editing event Jan 27 21:24:32 ... : event.startPosition = 5 Jan 27 21:24:32 ... : event.newCharacters = Q Jan 27 21:24:32 ... : self.nativeTextField.text = aasQdfaQ -- WRONG again but screen aasQQdfa Jan 27 21:24:32 ... : event.text = aasQdfaQ -- WRONG again but screen aasQQdfa ... now, in "ended" event ... Jan 27 21:25:20 ... : event.target.text = aasQdfaQ -- STILL WRONG on exit.  

I have checked the daily build logs and seen only 1209 and 1216 that address newTextField issues. This is only an iOS 7 issue in my build 1259, but I’m going to have to work around it somehow.

More recent discussion on this problem can be found here:

http://forums.coronalabs.com/topic/41321-ios-native-text-field-incorrectly-inserting-characters-if-cursor-is-moved/

As of 22 Nov 2013: it’s supposedly fixed in G2, and thus far, those who haven’t ported to G2 are out of luck.

What is the bug in 1260 that’s holding you back?

Rob