如何在textField上使用zIndex,这样当我在Titanium中按下一步时,我可以移动到其他textField

How to use zIndex on textField, so i can move to other textField when i press next in Titanium?

本文关键字:textField 下一步 移动 其他 Titanium 我可以 zIndex      更新时间:2023-09-26

>有人知道该怎么做吗? 我有这个代码:

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,但它对我不起作用。

知道吗?? 谢谢

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

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();
        });
    }
}