Giving a SearchBar focus does not open the keyboard
Hi,
I have a view where I would like the SearchBar to have focus when it's loaded, I've achieved this by calling the focus() method on the SearchBar in response to a Window open event. The problem is that even though it has focus the keyboard isn't displayed so the text box still needs another click, defeating the purpose.
Is there anyway around this?
Regards,
Chris
2 Answers
-
That is exactly what I do and works for me. Here is the code sample:
var win = Titanium.UI.currentWindow; // //Create the Search Bar // var search = Titanium.UI.createSearchBar({ showCancel:true, height:43, top:0, barColor:'#000', zindex:1 }); win.add(search); // set the focus on the search bar as soon as the window opens win.addEventListener('open', function(e) { Ti.API.info('Search window just opened'); search.focus(); });
-
Thanks Antonio, but that doesn't work for me. I'm using the android emulator.