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

SfListView how to prevent SfAutoComplete from capturing holding event so Swipe and Drag not starts

Hello,

If SfListView.ItemTemplate contains some entry, for example SfAutoComplete it prevents items reordering and swiping from start. In the example bellow you can start swiping and reordering by pressing "green" (Label) and "blue"(SfTextInputLayout) area, but green area capture everything, so swipe and reordering not starting.

 

I noticed also there is some problem with "blue area" (SfTextInputLayout), if you start swipe or reorder from "blue" it works fine, but when you release tap, the long press event is sent to SfAutoComplete and it shows "Copy/Paste" popup. 

 

Could you advise me how to stop SfAutoComplete from capturing long press and force it to bubble it up without doing anything? In perfect solution I would like to have 2 different behaviours depend if SfAutoComplete has focus or not.


1. If SfAutoComplete has focus than current behavior is ok.

2. If SfAutoComplete hasn't focus than:

a. SfTextInputLayout bubble long press and pan gesture up as it is now, and doesn't activate focus and send long press to SfTextInputLayout.Input

b. SfAutoComplete bubble long press and pan gesture up and doesn’t do anything 


Best regards,
Radek

<xForms:SfListView ItemsSource="{Binding Items}"

                           DragStartMode="OnHold"

                           ItemSize="70"

                           AllowSwiping="True">

            <xForms:SfListView.RightSwipeTemplate>

                <DataTemplate>

                    <Grid>

                        <Label Text="Right Swipe"/>

                    </Grid>

                </DataTemplate>

            </xForms:SfListView.RightSwipeTemplate>

            <xForms:SfListView.ItemTemplate>

                <DataTemplate>

                    <Grid ColumnSpacing="0">

                        <Grid.ColumnDefinitions>

                            <ColumnDefinition Width="1*"/>

                            <ColumnDefinition Width="3*"/>

                        </Grid.ColumnDefinitions>


                        <Label Grid.Column="0" Text="{Binding}" BackgroundColor="Green"/>


                        <textInputLayout:SfTextInputLayout Grid.Column="1" BackgroundColor="Blue">

                            <xForms1:SfAutoComplete Text="SfTextInputLayout" BackgroundColor="Red"/>

                        </textInputLayout:SfTextInputLayout>


                    </Grid>

                </DataTemplate>

            </xForms:SfListView.ItemTemplate>

        </xForms:SfListView>


Attachment: SfListView02_46bcfd48.zip

5 Replies

MK Muneesh Kumar G Syncfusion Team September 6, 2019 09:42 AM UTC

Hi Radoslaw, 
 
Greetings from Syncfusion.  
 
We have analyzed your query and we would like to inform you that if we focus to SfAutoComplete and press and hold, the clipboard will be shown. This is a default behavior of entry in Xamarin.Forms.  
 
Rather than that if your requirement is different from, please give more details about your requirement that would be helpful for us to give better solution in this.   
 
Thanks, 
Muneesh Kumar G 
 



RK Radoslaw Kubas September 6, 2019 10:07 AM UTC

Hello,

Thank you for you answer. 

Please check sample I attached in first post. The problem is that if SfAutoComplete is inside SfListView it is impossible to start SfListView reordering or swipe, because SfAutoComplete handles events (pan and long press). It would be perfect for example if those events were handled by SfListView (not by SfAutoComplete). I imagined perfect solution would be that if SfAutoComplete has already focus than it handles those events (can show copy/paste) but if hasn't already focus, then it would bubble those events up, to SfListView (if not focused, handles only Tap event to get focus). 

Similar behaviour would be necessary for SfTextInputLayout. Currently SfTextInputLayout bubble up events to SfListView, but also send them down to SfTextInputLayout.Input. If you start long press and pan by SfTextInputLayout part (not by part taken by Input), SfListView can start reorder and swipe, but just after those gestures completes, also Input control starts for example copy/paste.

Best regards,
Radek




KG Kanimozhi Gunasekaran Syncfusion Team September 9, 2019 11:46 AM UTC

Hi Radoslaw,  
 
We have checked the reported issue in SfAutoComplete inside the SfListView. In Xamarin Forms the parent or child any one element will handle the touch. So, while dragging the item the focus has been passed to SfAutoComplete, due to that parent event not calling in SfListView. If you need to work on scrolling and dragging, you should reduce the SfTextInputLayout size. It's the behaviour of the Xamarin Forms control. 
 
We have modified the given sample. Please try the attached below sample and let us know if you have any concern on this. 
 
Sample Link: 
 
Regards,
Kanimozhi G
 



RK Radoslaw Kubas September 10, 2019 08:49 AM UTC

Hello, 

Thank you for your support and hint. Anyway, I got some nice idea my own. I will share it here in case someone else has similar problem.

XAML:

<SfListView.ItemTemplate>
 <DataTemplate>

  <Grid>

   <SfTextInputLayout>
    <SfAutoComplete x:Name="AutoComplete">
   <SfTextInputLayout>

   <ContentView InputTransparent="{Binding Source={x:Reference AutoComplete}, Path=IsFocused, Mode=TwoWay}">
    <ContentView.GestureRecognizers>
     <TapGestureRecognizer Tapped="TapGestureRecognizer_OnTapped"/>
    </ContentView.GestureRecognizers>
   </ContentView>

  </Grid>

 </DataTemplate>
</SfListView.ItemTemplate>

CODE:
private void TapGestureRecognizer_OnTapped(object sender, EventArgs e)
{
 if (sender is ContentView content) content.InputTransparent = true;
}

It works almost perfectly (need some more code to open soft keyboard when input is focused).

Best regards,
Radek



MK Muneesh Kumar G Syncfusion Team September 10, 2019 09:15 AM UTC

Hi Radoslaw,   
 
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