Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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

— asked September 2nd 2010 by Francesco Gallo
0 Comments

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.

    — answered September 5th 2010 by Dan Tamas
    permalink
    0 Comments
  • This is the way it works, you will need to blur the searchview on cancel by yourself.

    — answered September 2nd 2010 by Dan Tamas
    permalink
    0 Comments
  • Thank you.

    How i can close searchbar when i tap out the input text on searchbar, instead of press cancel button?

    — answered September 2nd 2010 by Francesco Gallo
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.