Created
October 20, 2011 17:59
-
-
Save adampax/1301813 to your computer and use it in GitHub Desktop.
Simple Titanium form saved in an array with return key eventlistener moving to the next field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.UI.setBackgroundColor('#000'); | |
var win = Titanium.UI.createWindow({ | |
title : 'test' | |
}); | |
var arrayLength = 5 | |
var fields = new Array(arrayLength); | |
for( i = 0; i < arrayLength; i++) { | |
fields[i] = Ti.UI.createTextField({ | |
id : i, | |
height : 40, | |
width : 100, | |
hintText : 'Field ' + i, | |
value : '', | |
top : i * 50, | |
returnKeyType : i != arrayLength - 1 ? Titanium.UI.RETURNKEY_NEXT : Ti.UI.RETURNKEY_DONE, | |
borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED | |
}); | |
fields[i].addEventListener('return', function(e) { | |
var j = e.source.id; | |
if(j != arrayLength-1) { | |
fields[j + 1].focus(); | |
} else { | |
alert('Done'); | |
} | |
}); | |
win.add(fields[i]); | |
}; | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment