I am trying to have two separate windows. Where once you click on a button in window1, it takes you to window2 where you can enter info in a text field. Here when I go to the window2, the text field is not taking any input, after I click on it. The keyboard does not even show up.
Here is the code that switches to window2 from window1 at the click of a button:
simpleButton.addEventListener("click",function(e){ var eventWin = Ti.UI.createWindow({ url:'W2.js', title:'Events' }); eventWin.open(); });Here is the code available on window 2
var win2 = Titanium.UI.createWindow({ title:"Creating Text Fields and Text Areas", backgroundColor:"dcdcdc", exitOnClose:true }) var textField1 = Titanium.UI.createTextField({ top:60, height:60, width:300, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, //This is a constant that can be used to style textfields in iOS hintText:"Hint text" }); win2.addEventListener("click", function(e){ textField1.blur(); }); win2.add(textField1); win2.open();
2 Answers
Since the textField is added to the window, the win2.addEventListener will respond to the click event in the textField. In other words it will blur the text field as soon as you try to focus in it.
Use the source property of e in your click event to determine which element was clicked.
I just had a brainstorm... try this:
var win2 = Titanium.UI.createWindow({ title:"Creating Text Fields and Text Areas", backgroundColor:"dcdcdc", exitOnClose:true }) var focusCatcher = Ti.UI.createView({ top:0,bottom:0,left:0,right:0 }); win2.add(focusCatcher); var textField1 = Titanium.UI.createTextField({ top:60, height:60, width:300, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, //This is a constant that can be used to style textfields in iOS hintText:"Hint text" }); focusCatcher.addEventListener("click", function(e){ textField1.blur(); }); win2.add(textField1); win2.open();
Your Answer
Think you can help? Login to answer this question!