0

我的应用程序中有一个 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"
}
4

1 回答 1

0

使用与事件一起发送的属性。(文档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.
}
于 2012-08-09T12:20:25.460 回答