Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwipeGestureRecognizer does not raise Swiped event #16203

Open
MrThree12 opened this issue Jul 18, 2023 · 5 comments
Open

SwipeGestureRecognizer does not raise Swiped event #16203

MrThree12 opened this issue Jul 18, 2023 · 5 comments
Labels
area-gestures Gesture types platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@MrThree12
Copy link

Description

Adding SwipeGestureRecognizer to Button (Label or Border or FlexLayout) does not raise Swiped event. Also on Android it "overrides" Clicked event in button "properties" (when clicked it does not fire Clicked event), but it does not "override" on Windows (when clicked it fires Clicked event).

Steps to Reproduce

Create new MAUI project.
Update Button in MainPage.xaml:

<Button
    x:Name="CounterBtn"
    Text="Click me"
    SemanticProperties.Hint="Counts the number of times you click"
    Clicked="OnCounterClicked"
    HorizontalOptions="Center"
    >
    
    <Button.GestureRecognizers>
        <SwipeGestureRecognizer Swiped="SwipeGestureRecognizer_Swiped" Threshold="5" />
    </Button.GestureRecognizers>
</Button>

In MainPage.xaml.cs add event:

private void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
{
    count++;
    if (count == 1)
        CounterBtn.Text = $"Clicked {count} time";
    else
        CounterBtn.Text = $"Clicked {count} times";
    
    SemanticScreenReader.Announce(CounterBtn.Text);
}

Link to public reproduction project repository

https://github.com/MrThree12/mauiswipebug

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

Android 13 – API 33, Windows 10 – 10.0.19045

Did you find any workaround?

No

Relevant log output

No response

@MrThree12 MrThree12 added the t/bug Something isn't working label Jul 18, 2023
@MrThree12 MrThree12 changed the title SwipeGestureRecognizer does not raise Swipe event SwipeGestureRecognizer does not raise Swiped event Jul 18, 2023
@jsuarezruiz jsuarezruiz added the area-gestures Gesture types label Jul 18, 2023
@cdavidyoung
Copy link

@MrThree12, I am having the same problem. I am seeing this in the output whenever I attempt a swipe:

[GestureDetector] obtain mCurrentDownEvent. id: 532534320 caller: mono.android.view.View_OnTouchListenerImplementor.n_onTouch:-2 mono.android.view.View_OnTouchListenerImplementor.onTouch:31 android.view.View.dispatchTouchEvent:15540 
[GestureDetector] obtain mCurrentMotionEventRaw. action: 2 id: 506129181

@cdavidyoung
Copy link

I tested on iPhone as well with no success. There is no message in the output either.

@ghost
Copy link

ghost commented Jul 31, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Nov 28, 2023
@XamlTest
Copy link
Collaborator

Verified this on Visual Studio Enterprise 17.9.0 Preview 1(8.0.3). Repro on Android 14.0-API34, not repro on Windows 11 with below Project:
16203.zip

@RobTF
Copy link

RobTF commented Feb 8, 2024

This could be related to scroll views; for example the following results in the swipe gesture working, but scrolling breaks;

    <AbsoluteLayout Background="CornflowerBlue">
        <ScrollView AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="SizeProportional">
            <ScrollView.GestureRecognizers>
                <!-- These gestures work, but scrolling does not! -->
                <SwipeGestureRecognizer Swiped="SwipeGestureRecognizer_Swiped" Threshold="50" Direction="Left" />
                <SwipeGestureRecognizer Swiped="SwipeGestureRecognizer_Swiped" Threshold="50" Direction="Right" />
            </ScrollView.GestureRecognizers>
            <VerticalStackLayout>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="ZZZ" FontSize="30"/>
            </VerticalStackLayout>
        </ScrollView>
    </AbsoluteLayout>

If you move the gesture recognizer to the layout, the scrolling works but the swiping doesn't. It's like only one component in the mounted hierarchy can handle gestures, on iOS this is not a problem.

    <AbsoluteLayout Background="CornflowerBlue">
        <AbsoluteLayout.GestureRecognizers>
            <!-- These gestures are ignored, but user can scroll. -->
            <SwipeGestureRecognizer Swiped="SwipeGestureRecognizer_Swiped" Threshold="50" Direction="Left" />
            <SwipeGestureRecognizer Swiped="SwipeGestureRecognizer_Swiped" Threshold="50" Direction="Right" />
        </AbsoluteLayout.GestureRecognizers>
        <ScrollView AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="SizeProportional">
            <VerticalStackLayout>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="Welcome to .NET MAUI!" FontSize="30"/>
                <Label Text="ZZZ" FontSize="30"/>
            </VerticalStackLayout>
        </ScrollView>
    </AbsoluteLayout>

Seems there is no winning!! :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-gestures Gesture types platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants