-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[feature request] support custom handler for gestures #148
Comments
Of course you can. It behaves like any other |
could you give the key word? How to provide the block? I don't see a place I can provide my own block via a API. |
well I think I know what to ask: is there any public API to get the data set / xIndex etc. if I give a location (CGPoint) What I want is I can provide a touch location, and want to get the dataSet and xIndex, etc. to know what value is double tapped. |
Well I'm not in front of the code right now, but why won't you check out
the code of the tap handler? You'll see that there are helper functions for
everything...
|
I did, but it seems I have to write a function to get the data set or whatever given a location. I don't see a similar function do this in Utils. Just want to check if there is. I think this API is useful. |
What I am looking for is like below: public func xIndexAtPoint(point: CGPoint) -> Int {
var distance = distanceToCenter(x: point.x, y: point.y);
// check if a slice was touched
if (distance <= self.radius)
{
var angle = angleForPoint(x: point.x, y: point.y);
if (self.isKindOfClass(PieChartView))
{
angle /= _animator.phaseY;
}
var index = indexForAngle(angle);
// check if the index could be found
if (index < 0)
{
return NSNotFound;
}
else
{
return index;
}
} else {
return NSNotFound;
}
} Do you think such kind of functions is useful for other people? |
So why not just use xIndexAtPoint?
|
yeah I am using it. But I am wondering if such functions can be useful for others. |
Of course, they are not public for nothing...
|
@danielgindi , I think all the gesture handler function should be internal, or even public.
|
This is the PR #268 Better to let the gestures itself as internal discussed in PR, and you can have your own private gesture handlers. |
@liuxuan30 Great! |
@zxhfirefox i want to override doubletap on all say a batchart. Is there a way i can do it? UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touch:)]; add the gesture to the chartview. Any help in this respect will be world of good for me. |
You cannot have multiple tap gesture recognizers of the same type on the same view in iOS. They will conflict. Research it. It would be great if the library allowed us to add our own custom tap handler or gave us a tapped hook method. |
I looked at current swift code, seems like the gestures and private and I cannot provide custom handler to replace the default one?
Say if
PieRadarChartViewBase
has a doubleTapGestureRecognizer (which does not exist right now), the default behaviour is the zooming feature. Now I don't want zoom I want to double tap to be my own handler.I think the complicated part is supporting both Objective-C and swift block. I am not sure is there any evil there. like retain cycle or others.
The text was updated successfully, but these errors were encountered: