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
close icon

Trackball - No feedback/event when disappearing

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



11 Replies

HM Hemalatha Marikumar Syncfusion Team 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. 



JC Joan Caron 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


DD Devakumar Dhanapoosanam Syncfusion Team 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 



JC Joan Caron February 13, 2020 01:43 PM UTC

Thank you Devakumar Dhanapoosanam


JC Joan Caron February 19, 2020 06:36 AM UTC

Hello 

Do you have any feedback regarding this issue ?

Regards


DD Devakumar Dhanapoosanam Syncfusion Team 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 



JC Joan Caron February 19, 2020 06:35 PM UTC

That's perfect
Thank you a lot Devakumar Dhanapoosanam !


SJ Suyamburaja Jayakumar Syncfusion Team 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. 



WA Wanft March 20, 2023 09:12 PM UTC

I would like to request this to be implemented in the iOS component. We usually expect the same behavior in both platforms, and this surely is a "good to have" instead of having to implement custom renders.


att.



SM Saravanan Madheswaran Syncfusion Team March 23, 2023 05:41 AM UTC

Hi Tavares,


Thank you for your request. We understand the importance of having consistent behavior across platforms and we will do our best to provide a solution that meets your needs. Our team will review the request and We will update you with more details as soon as possible. Thank you for your patience and understanding.


Regards,

Saravanan.



SS Sowndharya Selladurai Syncfusion Team March 24, 2023 12:44 PM UTC

Hello Joan Caron,

 

We want to let you know that Xamarin.Forms does not currently offer support for Long press gesture recognize in trackball. And we have already considered Long press gesture recognize as a feature request and added it to our feature request list. You can track the status of this feature from the below feedback link.

 

Feedback:  https://www.syncfusion.com/feedback/42348/long-press-gesture-recognizer-support-for-sfchart.

 

We will prioritize the features every release based on the demand, and we do not have an immediate plan to implement this since we committed to already planned work. So, this feature will be available for any of our upcoming release.

 

Please cast your vote to make it count, and if you have any more specifications/suggestions for the feature request, you can add them as a comment in the feedback portal.

 

Regards,

Sowndharya Selladurai.


Loader.
Live Chat Icon For mobile
Up arrow icon