0

有谁知道这是怎么做到的吗?我有这个代码:

var txtOne = Titanium.UI.createTextField({
    top:50,
    zIndex:1
});

var txtTwo = Titanium.UI.createTextField({
    top:100
});

var txtThree = Titanium.UI.createTextField({
    top:150,
    zIndex:2
});

我想要的只是从 txtOne 跳转到 txtThree 而无需转到 txtTwo ..

我尝试使用 zIndex 但它不适用于我..

任何想法??谢谢

4

1 回答 1

2

您可以将它们放入一个数组中,并为它们的返回函数分配事件处理程序,如下所示:

var textFields = [txtOne, txtTwo, txtThree];

for(vat i=0; i < textFields.length; i++)
{
    //make the last text field jump to the first one when returning
    if(i == textFields.length-1)
    {
        textFields [i].addEventListener('return', function(e)
        {
            textFields[0].focus();
        });
    }
    else
    {
        //jump to the next text fields when returning
        textFields [i].addEventListener('return', function(e)
        {
            textFields[i+1].focus();
        });
    }
}
于 2013-10-29T08:43:03.677 回答