question

TaiLe-3992 avatar image
0 Votes"
TaiLe-3992 asked TaiLe-3992 commented

Touch Effect Conflict Events With Native Touch on Custom Renderer Xamarin Form

I had using Xamarin Form to custom my page with custom Renderer .
And custom Touch with Touch Effect: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/effects/touch-tracking

     <Grid.Effects>
                 <tt:TouchEffect Capture="True" TouchAction="OnTouchEffectAction"/>
             </Grid.Effects>
             <skia:SKCanvasView x:Name="myViewDraw" PaintSurface="DrawMyViewView_PaintSurface" BackgroundColor="Transparent"/>
         <ContentView x:Name="myCustom" x:FieldModifier="public" HorizontalOptions="Center" VerticalOptions="CenterAndExpand">
             <ext:myShareCustomCanvas x:Name="myShareCustomCanvas" HorizontalOptions="Fill" VerticalOptions="Fill"/>
         </ContentView>
  <Grid.Effects>

When I enable my custom Render Native iOS. TouchBegan,Move, End just fire once on Native View. And after event touch always fire from Touch Effect without fire Event on Native View myCustom. I try detect something but seem Touch Effect always top of MainPage. Hit events method in UIView Custom still received events from my Native Custom UIView.

         public override UIView HitTest(CGPoint point, UIEvent uievent)
         {
          return base.HitTest(point, uievent);
         }


But event overwrites Touch still no trigger in UIView:

        public override void TouchesBegan(NSSet touches, UIEvent evt)
         {
             base.TouchesBegan(touches, evt);
                
             foreach (UITouch touch in touches.Cast<UITouch>())
             {
                 long id = touch.Handle.ToInt64();
                //Do something
             }
         }






dotnet-xamarin
· 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@TaiLe-3992 I'm not sure what the problem is. Did you mean that the event was triggered only once? I tested the demo in the document and everything worked fine. Could you elaborate on the problem you encountered? It would be better if you can provide an example that reproduces the problem via Github or Onedrive.

0 Votes 0 ·

Sorry for the reply late @KyleWang-MSFT . I spend much time to debug but I can't detect what wrong. I upload a sample: https://1drv.ms/u/s!AklKIltmXW_TiEyR8dnev7qjaInn?e=M233h1

Please help me check that link. I think the touch effect has been adding native view onto it. And effect overlaps touches on native view.

0 Votes 0 ·

@TaiLe-3992 Did you try to override the TouchesBegan in the class "FingerPaintCanvasRenderer", rather than in "FingerPaintCanvasView"?

0 Votes 0 ·
Show more comments

0 Answers