how can i disable android auto text field focus
how can i disable android auto text field focus? It says Titanium.UI.TextField blur method will force the field to lose focus. How do I do this? Thanks
3 Answers
-
Travis
I would expect the following code to work as you expect, but demonstrates the problem you have:
Ti.UI.backgroundColor = "#FFFFFF"; var win = Ti.UI.createWindow({ exitOnClose: true }); var textField = Ti.UI.createTextField({ height:60, top:60, left:30, width:250 }); win.add(textField); win.open(); win.addEventListener('load', function(){ textField.blur(); })
Using the blur method will certainly hide the keyboard if it is showing, but when there is one or more textFields present in a window, it may be native behavior to have at least one with focus.
I will have to investigate, and get back to you.
Cheers
-
I ran into a similar problem. I wanted my textfield not to have the keyboard on window focus, but the textfield should show keyboard only when tapped. This is a behaviour that is there in iOS.
txtFieldSearch.softKeyboardOnFocus = Ti.UI.Android.SOFT_KEYBOARD_HIDE_ON_FOCUS; txtFieldSearch.addEventListener('click',function(e) { txtFieldSearch.setSoftKeyboardOnFocus(Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS); txtFieldSearch.focus(); });
Made my code work, simple and straight forward
-
Ran into the same issue today with Android auto focusing a text field on window load.
Here's the crude work around that worked for me:
//track your inputs on window into array, e.g. var inputs = []; //add inputs, etc... Ti.UI.currentWindow.addEventListener('focus',function(e){ setTimeout(function(){ for(var i in inputs){ inputs[i].blur(); } },1000);//adjust as needed });