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

[BUG] [Android] Dissalow further propagation for touch events #937

Open
FoggyFinder opened this issue Sep 3, 2019 · 8 comments · May be fixed by #953
Open

[BUG] [Android] Dissalow further propagation for touch events #937

FoggyFinder opened this issue Sep 3, 2019 · 8 comments · May be fixed by #953
Projects

Comments

@FoggyFinder
Copy link
Contributor

FoggyFinder commented Sep 3, 2019

Description

When SKCanvasView is placed inside, for example, ScrollViewer then touch events are intercepted even though e.Handled = args.Handled.

Here is a link to the SO topic with proper description of the issue:

ACTION_CANCEL while touching

And with advise how to handle it.

Code

With slight modification to demo app:

https://github.com/mattleibow/SkiaSharpDemo/tree/master/SkiaSharpDemo/SkiaSharpDemo

Add ListView to the bottom and Label to the top of the StackLayout:

    <ScrollView>
        <StackLayout>
            <Label Text="Some text" HorizontalOptions="Center" />
            <views:SKCanvasView HeightRequest="300"
                                WidthRequest="400"
                                HorizontalOptions="Center" 
                                PaintSurface="OnPainting" EnableTouchEvents="True" Touch="OnTouch" />
            <ListView  />
        </StackLayout>
    </ScrollView>

I also changed background color but it's doesn't related.

Expected Behavior

Content doesn't scroll when user drags inside of SKCanvasView.

Actual Behavior

It does scroll:

skDroid

Basic Information

  • Version with issue: latest stable (1.68.0)
  • Last known good version: none
  • IDE: Visual Studio
  • Platform Target Frameworks: - Android: 8.1

Reproduction Link

Since it's very easy to modify demo I haven't uploaded MCVE anywhere. But I could if it's required.

@Redth Redth added this to Needs Triage in Triage Sep 4, 2019
@charlesroddie
Copy link

@AxelUser can you look at a fix for this?
We tried disabling the scrollview on initial touch (after your PR in Xamarin.Forms) but that doesn't prevent subsequent touch events from being eaten by the scrollview.

@FoggyFinder FoggyFinder linked a pull request Sep 6, 2019 that will close this issue
4 tasks
@mattleibow
Copy link
Contributor

So, I had a look and tested a few things.

What I found was that UWP works in that as soon as you start drawing, it captures the pointer and won't scroll. This PR will fix it for Android.

I checked iOS and there is no easy way to prevent the bubbling of events, so it always scrolls. I fill that it is correct to stop scrolling, so we should probably fix iOS as well.

Not sure what Tizen, macOS, WPF will do.

But then again, maybe UWP is wrong. If you want to work with gestures and touch evens inside the canvas, you either disable the scroll on the scrollview, or you don't put the canvas inside the scrollview.

@FoggyFinder
Copy link
Contributor Author

I can check WPF but not iOS since I don't have device or emulator.
I've found this with quick search:

Stop ScrollView scrolling from child elements (works in Android but not iOS)

but I think there is easier and better way to achieve it.

@mattleibow
Copy link
Contributor

I think the issue is there is a bug: xamarin/Xamarin.Forms#8497

The correct way would be to track the touch events, and when you start dragging, you disable the scroll.

@kevcrooks
Copy link

kevcrooks commented Nov 15, 2019

Matching @FoggyFinder , we have the scrolling problem on Android.
iOS appears to be working as expected for us though @mattleibow (clicking and dragging inside the box doesn't scroll, which is what we want)

I think if your fix works for Android, then that would work in our case on all the devices we've tested.

---As an update: We were previously using a PanGestureRecognizer rather than the native SkiaSharp ones, which explains why we saw iOS working ok with the scrolling. Having just tested with the native SkiaSharp touch, we also do see a problem on iOS

@FoggyFinder
Copy link
Contributor Author

FoggyFinder commented Dec 5, 2019

I think the issue is there is a bug: xamarin/Xamarin.Forms#8497

@mattleibow I see. Almost 3 weeks past without any responses and I have feeling that it won't be changed in foreseeable future. No, really, I understand why - ScrollOrientation.Neither was added relatively recently and there are much more important bugs to fix.

The correct way would be to track the touch events, and when you start dragging, you disable the scroll.

But currently, as far as I can tell, there is no such way, isn't it?

I do think having a fix (even temporary) much better than nothing.

@vecalion
Copy link

vecalion commented Nov 9, 2020

Did anyone find a workaround for this issue?

@imuller
Copy link

imuller commented May 13, 2024

For .NET MAUI: dotnet/maui#18758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Triage
  
Needs Triage
Development

Successfully merging a pull request may close this issue.

6 participants