Pre loader

Separating Rollover/Tootips and Pan/Drag

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
0
0

Hello,

I’m wanting to switch to SciChart from a previous charting library. One neat thing that our previous library did that I cannot figure out how to do in SciChart is change the interaction between tooltips/rollover and panning.

What I would like to do is Pan/Drag the chart on short tap events, and do a rollover or tooltip cursor on long tap events. By default it looks like I get rollover and panning together on any tap event, which is not ideal behavior for my apps. Depending on the tap event type, I would like to do just one or the other, not both. How can I do something similar with SciChart?

Thank you,

Version
3.0.0.4253
  • You must to post comments
Best Answer
0
0

Hi there,

You can simulate touch event for RolloverModifier by calling its onTouch() when onLongPress() in CustomGestureModifier is called. This should show its content:

    @Override
    public void onLongPress(MotionEvent e) {
        super.onLongPress(e);

        // enable rollover after long press
        rolloverModifier.setIsEnabled(true);
        zoomPanModifier.setIsEnabled(false);

        // create touch event args for rollover modifier
        final ModifierTouchEventArgs args = new ModifierTouchEventArgs();
        args.e = e;
        args.isHandled = false;
        args.isMaster = true;
        args.isInSourceBounds = true;

        rolloverModifier.onTouch(args);

        args.clear();
    }

Hope this will help you!

Best regards,
Yura

  • C Bolton
    Thank you! That was the missing piece!
  • You must to post comments
0
0

Hi Yura,

That link got me part way there. I can enable/disable the operations successfully. Where I am having trouble is on the longpress event. After enabling the rolloverModifier, the rollover does not appear until a subsequent Move event. Is there any way for me to force the rollover to appear on the longpress event itself instead of waiting for a Move? My code for the custom gesture modifier is below.

class CustomGestureModifier(private val rolloverModifier: RolloverModifier,private val zoomPanModifier: ZoomPanModifier) :GestureModifierBase() {

override fun onLongPress(e: MotionEvent?) {
    // enable rollover after long press
    /*
    This is the problem, rollover does not appear until subsequent MOVE event.
    Can rollover be forced programatically at this point?
     */
    rolloverModifier.isEnabled = true
    zoomPanModifier.isEnabled = false

    super.onLongPress(e)
}

override fun onUp(e: MotionEvent?) {
    super.onUp(e)
    // disable rollover after touch up
    rolloverModifier.isEnabled = false
    zoomPanModifier.isEnabled = true
}

override fun onScroll(
    e1: MotionEvent?,
    e2: MotionEvent?,
    distanceX: Float,
    distanceY: Float
): Boolean {
    // disable rollover on scroll
    rolloverModifier.isEnabled = false
    zoomPanModifier.isEnabled = true
    return true
}

override fun onFling(
    e1: MotionEvent?,
    e2: MotionEvent?,
    velocityX: Float,
    velocityY: Float
): Boolean {
    Log.d(TAG, "OnScroll")
    rolloverModifier.isEnabled = false
    zoomPanModifier.isEnabled = true
    return true
}

init {
    // disable rollover by default
    rolloverModifier.isEnabled = false
    zoomPanModifier.isEnabled = true
}

}

  • Yura Khariton
    Without seeing the entire code I would suggest to try to set this custom modifier as first modifier ( so it processes events and sets IsEnabled for rollover and zoom pan modifiers before other modifiers ). Also I would ask you to check if rollover has ReceiveHandledEvents = true. In this case RolloverModifier should have a chance to process touch event right after you set IsEnabled = true for it, instead of waiting for next touch event in case if it’s defined before CustomGestureModifier. Can you try it?
  • You must to post comments
0
0

Thanks Yura, I tried both of those, but it didn’t resolve the problem. Here’s the code I’m using to create/add the modifiers:

    val chartModifiers = chartSurface.chartModifiers

    val rolloverModifier = RolloverModifier()
    val zoomPanModifier = ZoomPanModifier()
    val customGestureModifier = CustomGestureModifier(rolloverModifier, zoomPanModifier)

    rolloverModifier.receiveHandledEvents = true
    chartModifiers.add(rolloverModifier)
    chartModifiers.add(zoomPanModifier)
    // if added first, it still doesn't show cursor on longPress, plus it then doesn't hide cursor on onUp
    chartModifiers.add(customGestureModifier) 

Without seeing the SciChart source code, its like the rolloverModifier is not designed to show the cursor on longPress (normally it would just show it on a simple down touch), so passing the longPress through doesn’t trigger anything in the rolloverModifier?

Thanks again for your assistance.

  • You must to post comments
0
0

Hi there,

Unfortunately we don’t support this behavior out of the box, but it can be done using custom chart modifiers API. There is a similar question which may help you.

Hope this will help you!

Best regards,
Yura

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies