SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

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.