appceleratorappcelerator-titaniumappcelerator-alloyappcelerator-studio

how to add return key to Titanium searchbar for ios


I am working on an app.I am getting an issue in searchbar. When search bar has no text then it disables "Search" key and user is stuck at screen.

Search key gets enabled when user starts entering text in it.

I want to add retu key instead of search key in Appcelerator titanium searchbar where it should work as return key.Pressing return key should hide keyboard.

Thanks in advance.


Solution

  • You will need to add manual code to hide keyboard on click on SearchBar's Cancel button.

    Following code should work as expected:

    <SearchBar id="search" showCancel="true" cancelButtonTitle="Hide" onCancel='hideKeyboard' />
    
    function hideKeyboard(e) {
        // it will hide the keyboard as well
        $.search.blur();
    }
    

    You can use other events to track if searchbar is empty or not, or when to hide keyboard or when to clear search-text, etc.