We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

autoComplete.IsFocused = false doesn't hide keyboard on Android

Hello,

I need to unfocuse SfAutoComplete when Pan gesture started on other control. I used simple code like "autoComplete.IsFocused = false ". On iOS it seems to works fine, but on Android, behaviour is strange. Control looks unfocused, but soft keyboard stays open (but change its looks).

To reproduce just:

xml:
<StackLayout>
     <SfAutoComplete x:Name="autoComplete"/>
</StackLayout>

<Label Text="Pan to Unfocus">
     <Label.GestureRecognizers>
          <PanGestureRecognizer PanUpdated="PanGestureRecognizer_OnPanUpdated"/>
     </Label.GestureRecognizers>
</Label>

code:
private void PanGestureRecognizer_OnPanUpdated(object sender, PanUpdatedEventArgs e)
{
     autoComplete.IsFocused = false;
}

Regards,
Radek

3 Replies

MK Muneesh Kumar G Syncfusion Team August 5, 2019 09:39 AM UTC

Hi Radoslaw, 
 
Greetings from Syncfusion. 
 
We have achieved your requirement by using custom renderer to dismiss the keyboard when focus got changed in SfAutoComplete Control. Please have the sample from the below link. 
 
 
Code Snippet: 
 private void Control_FocusChanged(object sender, Com.Syncfusion.Autocomplete.FocusChangedEventArgs e) 
        { 
            if (!e.HasFocus) 
            { 
                this.inputManager = (InputMethodManager)this.Context.GetSystemService(Android.Content.Context.InputMethodService); 
                this.inputManager.HideSoftInputFromWindow(Control.GetAutoEditText().WindowToken, 0); 
            } 
        } 
 
Please check with the sample and let us know if you have any concern. 
 
Thanks,    
Muneesh Kumar G.    
 



RK Radoslaw Kubas August 7, 2019 05:40 AM UTC

Hello,

Thank you very much for help, it works like a charm. I also noticed that this issue was fixed in the latest SfAutoComplete version. Am I right?

Anyway, once again thank you for amazing support.

Best regards,
Radek


MK Muneesh Kumar G Syncfusion Team August 7, 2019 07:33 AM UTC

Hi Radoslaw,  
 
Thanks for your update.  
 
We didn’t include any fix in our latest version. However, we glad that the issue has been resolved and please get back to us if you need any other assistance.  
 
Thanks, 
Muneesh Kumar G. 


Loader.
Live Chat Icon For mobile
Up arrow icon