Titanium API Textfield翻倍

时间:2012-08-08 18:42:15

标签: titanium

我的应用中有一个TextField,它在文本上加倍。我的意思是,如果我输入“dog”,它会返回“dogDog”,注意它是如何大写的吗?

var searchText = Ti.UI.createTextField({
      borderRadius:5,
      hintText : 'Enter Search Text',
      color:"#0000FF",
      borderColor:"#0000FF",
      font:{fontSize: 30},
      width:400,
      top:50
});
searchText.addEventListener('return',textEntered);

function textEntered(){
 Titanium.API.info(searchText.getValue());// logs "dogDog" when should be "dog"
}

1 个答案:

答案 0 :(得分:0)

使用与事件一起发送的属性。 (doc http://docs.appcelerator.com/titanium/2.1/#!/api/Titanium.UI.TextField-event-return

searchText.addEventListener('return',textEntered);

function textEntered(source,type,value){
    Titanium.API.info(value); // should just log 'dog'
    // var type should contain 'return'
    // var source should contain the searchText object.
}
相关问题