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!
- Dok God asked 5 years ago
- You must login to post comments
Hi, there.
You can achieve this by subscribing to “gestureRecognizerShouldBegin” and “shouldReceive touch” delegate events and disable/enable your modifiers there.
-
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 }()
-
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)
-
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 }
-
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
- Andriy P answered 5 years ago
- last edited 5 years ago
- You must login to post comments
Please login first to submit.