searchbar blur
Hi everybody!
I try to get event blur when i touch out searchbar but it don't work.
I correct get cancel event, but blur seem doesn't work.
this is the code:
var searchb = Titanium.UI.createSearchBar({
barColor: '#000',
showCancel: true,
height:43,
hintText:' Cerca hotel e prova',
top:0
});
searchb.addEventListener('cancel',function (e)
{
alert('ok');
});
searchb.addEventListener('blur',function (e)
{
label2.text = 'search';
});
win2.add(searchb);
When I tap on searchbar the keyboard goes out, when i tap on "cancel" the alert come out correctly, but when i tap on searchbar and after tap out the "blur" event didn't fire.
If i force blur ( searchb.blur() ) the code into function "blur" works.
Any suggestion?
Thank you very much
3 Answers
-
Accepted Answer
You can catch the click event for the whole window, and if the source of the event is not the searchbar, to trigger a blur() for it.
Nothing happens if blur triggers when the searchbar is already blurred. -
This is the way it works, you will need to blur the searchview on cancel by yourself.
-
Thank you.
How i can close searchbar when i tap out the input text on searchbar, instead of press cancel button?