Usecase: A tabgroup with 2 tabs has a tableview on the 2nd tab with a textfield on a row. After a touch on the textfield the keyboard pops up but then the textfield loses focus(ie. there is no cursor in the field).
(Also when using Ti.UI.KEYBOARD_NUMBERS_PUNCTUATION, it only pops up after touching the textfield the second time.)
Any ideas?
app.js:
var win1 = Ti.UI.createWindow({}) var tab1 = Ti.UI.createTab({ window: win1 }); var win2 = Ti.UI.createWindow({}) var row = Ti.UI.createTableViewRow({}) var tF = Ti.UI.createTextField({value: ''}) row.add(tF) var tV = Ti.UI.createTableView({data:[row]}) win2.add(tV) var tab2 = Ti.UI.createTab({ title:'', window: win2 }); var tabGroup = Ti.UI.createTabGroup() tabGroup.addTab( tab1 ) tabGroup.addTab( tab2 ) tabGroup.open({ })Titanium SDK 1.6.1, Android SDKs: APIs 2.2 / APIs 2.3.1
10 Answers
The issue I was running into wasn't exactly as detailed in original posting since I wasn't using a tabbed view but instead opening a new window. I managed to workaround the problem by making that window modal, not sure if that helps you at all or not.
I noticed that Android textField events are erratic, including loosing focus immediately after focussing making input impossible. They seem to be especially bad in a tableViewRow.
So to filter out junk events I've done this:
textfield.addEventListener('focus', function() { var that = this; this.focus_timer = setTimeout( function() { // True focus commands here that.focus_timer = 0; }, 500); if(this.blur_timer > 0) { clearTimeout(this.blur_timer); this.blur_timer = 0; } }); textfield.addEventListener('blur', function() { var that = this; this.blur_timer = setTimeout( function() { // True blur commands here that.blur_timer = 0; }, 500); if (this.focus_timer > 0) { clearTimeout(this.focus_timer); this.focus_timer = 0; this.focus(); } });Hope this helps.
bumping my new usecase
I also ran into this problem today, is there any news on this? Thanks!
I have also been fighting with this problem. Is there any update or news on this?
has anybody found a workaround for this? (i've been trying to fix this for three months now... no success). Has anybody opened a ticket on the new issue tracker jira.appcelerator.org (i can't find a corresponding ticket to this problem...) ?
Any updates on this?
Try insert a View inside the Window and the TableView inside the View. It works for me.
var self = new Window(); var viewContainer = new View({ top : '10dp', bottom : '10dp' }); self.add(viewContainer); var tableView = new TableView(); viewContainer.add(tableView);
Here is a fix for this...
fieldName.addEventListener('focus',function(){ setTimeout(function(){ fieldName.focus(); },500); });by no means is this ideal, but in my issue, the keyboard always stayed up but the field only lost focus. So I simply did a check after half a second... and re focused the field. The user wouldn't really even notice.
Your Answer
Think you can help? Login to answer this question!