Hello All,
I have an iOS project that implements bar charts with several types of user interaction. Everything works fine. Swipe to pan with axis constraints, pinch zooming on a single axis (CPTPlotSpaceDelegate) and selecting a bar (barWasSelectedAtRecordIndex). Excellent, so far so good.
One problem -- it was very easy with all the swiping and pinching going on to inadvertently trigger a new bar selection. So I set about seeing how I could ignore single taps on bars and just handle double-taps. To do this, I have to (a) have a hook to the event to count taps and (b) discover the index of the selected bar.
I started with the CPTPlotSpaceDelegate event handling methods. shouldHandlePointingDeviceDownEvent worked great on double-taps outside bars, but did not respond to taps inside the bars. Peeking into CPTBarPlot.m, I found that -- quite reasonably -- this is by design. If its delegate implements barWasSelectedAtRecordIndex, CPTBarPlot.m handles the pointingDeviceDown event by identifying the tapped bar and messaging the delegate. This makes perfect sense, but left me with the problem of finding a way to ignore single taps.
In the end I could not find a way to get both (a) and (b) using the API. So I met my needs by modifying CPTBarPlot.m (ever so slightly) to invoke barWasSelectedAtRecordIndex only on double taps. (-(BOOL)pointingDeviceDownEvent:(id)event atPoint:(CGPoint)interactionPoint) . Works like a charm, but it meant fiddling with the framework.
After all that, my question is - is there a better, i.e. non-invasive way of solving this problem?
Last comment - this is my first post so let me express my thanks to the developers of this wonderful framework. Great work, thanks for your efforts.
David