Forum Xamarin Xamarin.iOS

How to ignore keyboard input without hiding the keyboard

MarthughieMarthughie GBMember ✭✭

On of my views is a search text box which populates a list. The user is allowed to incrementally search (that is to keep on typing a criterion, and after a short delay after they stop typing - of about 400ms or so - a search is started).

What I don't want to allow however, is any user input from the keyboard to kick off a new search whilst there is one underway. I don't want to keep hiding and showing the keyboard in between incremental searches as that would be visually noisy, so is there a way I can continue to show the keyboard but have it disabled during a search window.



  • JoeProJoePro CAUniversity ✭✭✭

    Not sure if you can disable the keyboard, but maybe you can ignore keypresses while a search is already in progress. You should be able to do just that by using the 'ShouldChangeCharacters' delegate method on UITextField.

    I used a different approach on an address text box. I launch a new background search on keypress, without delay. However, using a custom task scheduler, I limit those background searches to one at a time and queue up the most recent one only. Not only did this simplify my code, it also improved performance as well as user experience a whole lot.

  • MarthughieMarthughie GBMember ✭✭

    @JoePro many thanks for your comments. I will have a think about the best way to do this. Following on from your suggestion to allow the user enter what they want, another option is to simply cancel any outstanding search at the time a new one is issued. As I am searching via HttpClient, I think the CancelPendingRequests method may help here.

Sign In or Register to comment.