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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Trackball - No feedback/event when disappearing

Thread ID:

Created:

Updated:

Platform:

Replies:

151354 Feb 7,2020 02:21 PM UTC Feb 20,2020 07:06 AM UTC Xamarin.Forms 8
loading
Tags: SfChart
Joan Caron
Asked On February 7, 2020 02:21 PM UTC

Hello 

When the property ActivationMode from ChartTrackballBehavior is set to "LongPress" I can't get any feedback when the trackball disappear. 
But when it's set to "TouchMove" the "TouchUp" event is fired and that's what I need because I want to display/hide some parts of the UI.

Is there any way to have this event fired or any feedback when using "LongPress"  ?

Thanks in advance



Hemalatha Marikumar [Syncfusion]
Replied On February 10, 2020 12:06 PM UTC

Hi Joan Caron, 
  
Greetings from Syncfusion. 
  
QueryIs there any way to have this event fired or any feedback when using "LongPress"? 
  
Yes. It is possible and your requirement has been achieved by using the OnLongPress and OnTouchUp override methods of ChartTrackballBehavior as in below code snippet.  
C#: 
public class TrackballBehaviorExt : ChartTrackballBehavior 
{ 
   private bool isLongPressActivated = false; 
  
   protected override void OnLongPress(float pointX, float pointY) 
   { 
       base.OnLongPress(pointX, pointY); 
       isLongPressActivated = true; 
   } 
  
   protected override void OnTouchUp(float pointX, float pointY) 
   { 
       base.OnTouchUp(pointX, pointY); 
       if (isLongPressActivated) 
       { 
          isLongPressActivated = false; 
          //Write your logic here 
       } 
   } 
} 
  
Please let us know if you need any further assistance on this. 
 
Regards,
Hemalatha M. 


Joan Caron
Replied On February 12, 2020 09:46 AM UTC

Thank you for your quick answer!
But it doesn't cover what I want..

The event OnTouchUp is not fired when ActivationMode is set to LongPress
I need to run my Logic when the user stops interacting with the trackball like when OnTouchUp event occurs

Devakumar Dhanapoosanam [Syncfusion]
Replied On February 13, 2020 01:41 PM UTC

Hi Joan Caron, 
 
Currently we are validating the reported issue at our end and will update you the details on February 17, 2020.  
 
Regards, 
Devakumar D 


Joan Caron
Replied On February 13, 2020 01:43 PM UTC

Thank you Devakumar Dhanapoosanam

Joan Caron
Replied On February 19, 2020 06:36 AM UTC

Hello 

Do you have any feedback regarding this issue ?

Regards

Devakumar Dhanapoosanam [Syncfusion]
Replied On February 19, 2020 01:11 PM UTC

Hi Joan Caron, 
 
Sorry for the delay. Already provided solution is worked fine in Android platform. For iOS only we have some limitation. We can overcome this in iOS by using CustomRenderer in it calling the TouchUp method to resolve the issue as per in below codesnippet. 
 
C#: 
public class ChartTrackballBehaviorExt : ChartTrackballBehavior 
{ 
     public ChartExt chart { get; set; } 
     public ChartTrackballBehaviorExt() 
     { 
 
     } 
 
     protected override void OnLongPress(float pointX, float pointY) 
     { 
          chart.TrackballVisible = true; 
          base.OnLongPress(pointX, pointY); 
     } 
     //For Android this override OnTouchUp will work fine after LongPress 
     protected override void OnTouchUp(float pointX, float pointY) 
     {  
          base.OnTouchUp(pointX, pointY); 
     } 
       
     //For iOS after long press TouchUp method called here 
     public void TouchUp(float pointX, float pointY) 
     { 
         if (chart != null) 
         { 
              chart.TrackballVisible = false; 
              //check your logic here for iOS 
         } 
     } 
} 
 
C#:  
class CustomChartRenderer : SfChartRenderer 
{ 
   protected override void OnElementChanged(ElementChangedEventArgs<SfChart> e) 
   { 
       base.OnElementChanged(e); 
 
       var formsChart = Element as Syncfusion.SfChart.XForms.SfChart; 
 
       for (int i = 0; i < formsChart.ChartBehaviors.Count; i++) 
       { 
             if (formsChart.ChartBehaviors[i] is  Syncfusion.SfChart.XForms.ChartTrackballBehavior) 
             { 
                  var formsTrackball = formsChart.ChartBehaviors[i] as     
                                        Syncfusion.SfChart.XForms.ChartTrackballBehavior;                                                        Control.Behaviors.Remove((SFChartBehavior)SfChartRenderer.GetNativeObject(typeof 
                                    (Syncfusion.SfChart.XForms.ChartTrackballBehavior), formsTrackball)); 
                  CustomTrackballBehavior customTrackball = new CustomTrackballBehavior(); 
                  customTrackball.FormsBehavior = formsTrackball; 
 
                  var properties =  
SfChartRenderer.GetPropertiesChanged(typeof(Syncfusion.SfChart.XForms.ChartTrackballBehavior),   
                                     formsTrackball); 
                  foreach (var name in properties) 
                  {                                                                 
                        ChartTrackballBehaviorMapping.OnChartTrackballBehaviorPropertiesChanged(name,    
                                 formsTrackball, customTrackball); 
                  } 
                                                             
               SfChartRenderer.SetNativeObject(typeof(Syncfusion.SfChart.XForms.ChartTrackballBehavior),  
                                 formsTrackball, customTrackball); 
                 Control.Behaviors.Insert(i, customTrackball); 
             } 
         } 
     } 
} 
 
public class CustomTrackballBehavior : ChartTrackballBehaviorHelper 
{ 
      public override void LongPressWithGestureRecognizer(UILongPressGestureRecognizer   
                                            longPressGestureRecognizer) 
      { 
               base.LongPressWithGestureRecognizer(longPressGestureRecognizer); 
              var locationInChart = longPressGestureRecognizer.LocationInView(Chart); 
              if (UIGestureRecognizerState.Ended == longPressGestureRecognizer.State) 
              { 
                     (FormsBehavior as ChartTrackballBehaviorExt).TouchUp((float)locationInChart.X,  
                                     (float)locationInChart.Y); 
               } 
     } 
} 
 
XAML: 
 
<local:ChartExt x:Name="chart" HorizontalOptions="FillAndExpand"   
          VerticalOptions="FillAndExpand"> 
      …. 
      <chart:SfChart.ChartBehaviors> 
        <local:ChartTrackballBehaviorExt chart="{x:Reference chart}"  
                 ActivationMode="LongPress"> 
        </local:ChartTrackballBehaviorExt> 
   </chart:SfChart.ChartBehaviors> 
</local:ChartExt> 
 
 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Devakumar D 


Joan Caron
Replied On February 19, 2020 06:35 PM UTC

That's perfect
Thank you a lot Devakumar Dhanapoosanam !

Suyamburaja Jayakumar [Syncfusion]
Replied On February 20, 2020 07:06 AM UTC

  
Hi Joan Caron, 
 
We glad to know the given solution works, 
 
Please let us know if you need any further assistance and please don't hesitate to contact us. 
 
Regards, 
Suyamburaja J. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon