Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tap Gesture Handler callback method #2686

Closed
ghost opened this issue Aug 7, 2017 · 4 comments
Closed

Tap Gesture Handler callback method #2686

ghost opened this issue Aug 7, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 7, 2017

Hi,

Great library -- thanks for all the hard work on your end.

We are trying to add a tap gesture recognizer on an instance of BaseChartView. Why? We would like a custom action to occur on chart tap down. highlightValue does not help us because its called whenever the chart value is highlighted. So if the user taps down, then rolls their finger ("swipe"), highlightValue could potentially be called hundreds of times. We only want to send our custom action once on tap down.

When trying to add our own tap gesture recognizer on the chart, we interfere with the existing tap gesture recognizer that the library provides. This appears to be a limitation of iOS -- we cannot have multiple instances of the same type of tap gesture recognizer on a view. We've also tried other hacks, like using cancelsTouchesInView in our tap gesture recognizer, etc.

What would it take to get an "on tapped" callback method by the API? Looking at the internal tap gesture recognizer, it looks like it might be pretty trivial. However I'm no expert and didn't feel ready to make a pull request.

@objc private func tapGestureRecognized(recognizer: NSUITapGestureRecognizer)
    {
        if _data === nil
        {
            return
        }
        
        if (recognizer.state == NSUIGestureRecognizerState.Ended)
        {
            if !self.isHighLightPerTapEnabled { return }
            
            let h = getHighlightByTouchPoint(recognizer.locationInView(self))
            
            if (h === nil || h!.isEqual(self.lastHighlighted))
            {
                self.highlightValue(highlight: nil, callDelegate: true)
                self.lastHighlighted = nil
            }
            else
            {
                self.lastHighlighted = h
                self.highlightValue(highlight: h, callDelegate: true)
            }
        }
    }
@liuxuan30
Copy link
Member

the gesture handler is a private one. So you can easily sub class the chart view and provide your own.

@ghost
Copy link
Author

ghost commented Aug 11, 2017

What if I want the original functionality plus the custom new functionality?

@liuxuan30
Copy link
Member

copy paste the code and add your code :)

@zzyspace
Copy link

@liuxuan30 the gesture handler is a private one. So you can easily sub class the chart view and provide your own.

On Objective-C can not subclass the chart view:
wx20181116-102940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants