Replacing the textfield value makes the cursor go back before the first character. Works correctly on iOS.
1. Run the Sample Code
2. Put one character into the textfield
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
var textfield = Titanium.UI.createTextField({
color:'#336699',
value:'',
height:35,
width:300,
top:10,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
keyboardToolbarColor: '#999',
keyboardToolbarHeight: 40,
autocapitalization: Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
autocorrection: false
});
win1.add(textfield);
textfield.addEventListener("change",function(e){
if(textfield.value.length>0) textfield.value = "test";
});
win1.open();
The required solution is much bigger than expressed in this ticket and its test case. TIMOB-6006 was created to expose the appropriate APIs to allow this to be solved by the application developer.