Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Hide the keyboard (blur) when clicking out of a textField inside a tableView in Titanium

$
0
0

Hi, I'm developing in a Mac for IOS and Android and I'm using Titanium 3.1.0.

I'm trying to get a table in Titanium where each row has a static text and a textField where I can input something.

So I go and create a row where it's left part is the static text and the right part a my input text field. Just a small problem, I can't hide the keyboard by clicking outside of it.

If it was a normal textField outside a table I would just use the blur method, but in this case I can't get that to work.

This is my code so far: Any idea on how this works and if the solution is valid for both iOS and Android?

var winAddObjectView = Titanium.UI.currentWindow;
 
var tableAddObjectData = [
    {title:'name', hintText:'item name (optional)'},
    {title:'track no.', hintText:'object tracking code'}
];
 
var tableAddObjectRowData = [];
for (var i = 0; i < tableAddObjectData.length; i++) {
    var title = Ti.UI.createLabel({
        text:tableAddObjectData[i].title,
        textAlign:"right",
        left:"20",
        height:'auto',
        width:'68',
        color:'#526691',
        font:{fontSize:12, fontWeight:'bold'},
    });
    var textField = Ti.UI.createTextField({
        hintText:tableAddObjectData[i].hintText,
        textAlign:"left",
        left:"96",
        height:'auto',
        width:'184',
        color:'#4C4C4C',
        font:{fontSize:12, fontWeight:'bold'},
    });
 
    winAddObjectView.addEventListener("click", function(e){
        textField.blur();
    });
 
    var row = Ti.UI.createTableViewRow({
        height:"45",
    });
 
    row.add(title);
    row.add(textField);
    tableAddObjectRowData.push(row);
}
 
var tableAddObjectView = Ti.UI.createTableView({
    headerTitle:'Enter Tracking Information',
    style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
    backgroundColor:'transparent',
    data:tableAddObjectRowData,
});
 
winAddObjectView.add(tableAddObjectView)

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>