iPhone textField auto-correction bug
Creating a textField by doing something like this:
inline code
var tf = Titanium.UI.createTextField({
top: fieldPosition,
left: fieldLeft,
height: fieldHeight,
width: fieldWidth,
borderStyle: fieldBorderStyle,
value: fields.fieldByName(fname)
});
tf.addEventListener('change', mkSaver(tableName, fname, tf));
Where the Saver function stores the tf.value away. This work just fine.
—– HOWEVER ——
You have seen that when typing into a textfield, iPhone will suggest capitalization, or spelling changes, etc…
If the user accepts those auto-corrections, the textField changes on screen, but NO CHANGE EVENT is triggered.
In my case, this results in a difference between what's stored by the function, and what ends up appearing on the screen.
I have also tried storing on 'return', and the same will hold true. The screen shows the auto-capitalization or correction, but tf.value has all lower case, or whatever the user typed. Even if I allow the capitalization, and then hit return (catching the return event) after the correction was made.
Titanium 1.0 and mobile SDK 1.0
Macbook pro snow leopard
running on iPhone simulator
Regards,
Ron
5 Answers
-
I see similar behavior on the simulator and on device. If I type something into a textfield, then edit that textfield, the "value" property doesn't seem to match what's displayed on-screen.
This happens with autocorrect disabled and enabled.
-
Check Kitchen Sink they have an undocumented property
autocapitalization
in the textfields that controls this. I wish Appcelerator would properly maintain their documentation.Possible Values of the property:
Ti.UI.TEXT_AUTOCAPITALIZATION_ALL Ti.UI.TEXT_AUTOCAPITALIZATION_NONE Ti.UI.TEXT_AUTOCAPITALIZATION_SENTENCES Ti.UI.TEXT_AUTOCAPITALIZATION_WORDS
Example from Kitchen Sink:
var username = Ti.UI.createTextField({ autocapitalization:Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE, width:300, top:10, height: 35, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, hintText:'Username' }); win.add(username); var password = Ti.UI.createTextField({ autocapitalization:Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE, width:300, top:55, height:35, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, passwordMask:true, hintText:'Password' });
-
i have exactly the same behaviour and not just the missing change event, with no event handling the value has not changed
-
I believe Nolan has entered a bug report for this issue.
Ron
-
i prefer to save the data with the "blur" event.