Pre loader

How can I add CursorModifier on long tap, after scrolling?

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

0
0

When I add CursorModifier programmatically on long tap I have to remove my finger from screen and press it again In order to CursorModifier become visible

Is it possible to do the following?


1) scroll chart horizontally

2) long tap on screen

3) add CursorModifier programmatically and show it immediately

4) move CursorModifier(finger is still touching the screen)

5) remove finger from screen and remove CursorModifier so I can scroll again

Thank you for reply in advance!

Version
2.2.1.2267
  • You must to post comments
1
0

Hi, there.

You can achieve this by subscribing to “gestureRecognizerShouldBegin” and “shouldReceive touch” delegate events and disable/enable your modifiers there.

  1. Create your Long Press Gesture recognizer and add it to your view

    private lazy var longPress: UILongPressGestureRecognizer = {
        let longPress = UILongPressGestureRecognizer()
        longPress.cancelsTouchesInView = false
        longPress.delegate = self
    
        return longPress
    }()
    
  2. Create your modifiers and add them to the Surface

    private let zoomPan = SCIZoomPanModifier()
    private let cursorModifier = SCICursorModifier()
    
    self.surface.chartModifiers.add(self.zoomPan)
    self.surface.chartModifiers.add(self.cursorModifier)
    
  3. Subscribe to UIGestureRecognizerDelegate events

    override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        zoomPan.isEnabled = false
        cursorModifier.isEnabled = true
        return true
    }
    
    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
        cursorModifier.isEnabled = false
        zoomPan.isEnabled = true
        return true
    }
    
  4. Long-press and move your finger. You should start to see cursor without removing the finger from the screen
    Let us know if it helps

  • You must to post comments
Showing 1 result
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