Plot Element Selection — Basic Advice

9 views
Skip to first unread message

Mike Rossetti

unread,
May 23, 2013, 11:23:47 PM5/23/13
to coreplot...@googlegroups.com
Is there a recommended way, on iOS, for handling tap selection of the various plot elements? For example, tapping on a plot line so that the attributes of the plot can be changed. Or tapping on an axis so that the axis attributes can be changed?

It looks like the pointingDeviceDraggedEvent:atPoint: function, and akin, are dispatched nicely to each of the elements in a graph and its plots. Can I simply handle the pointingDeviceUpEvent:atPoint: to detect a 'selection'? Or do I have to detect the initial pointingDeviceDownEvent:atPoint:, and the pointingDeviceCancelledEvent: to make sure that the 'down' and 'up' taps happened in the same element and wasn't 'cancelled' in the meantime? (It wouldn't be very good if the user tapped somewhere else on the graph, dragged over to on axis, and let go and that triggers a selection of the axis.)

I didn't see this kind of behavior in any of the examples.

Mike

Eric

unread,
May 24, 2013, 10:34:47 AM5/24/13
to coreplot...@googlegroups.com
You'll need to subclass the parts that you want to respond to touch (plots, axis set/axes, etc.) and implement the methods you mention. Which ones you implement depend on the behavior you want. If you want the selection to appear immediately, -pointingDeviceDownEvent:atPoint: is fine. If you want to wait until the user lifts their finger or you want to allow dragging over various elements, you'll need the other methods, too.

Eric

Eric

unread,
May 24, 2013, 4:29:08 PM5/24/13
to coreplot...@googlegroups.com
Easier than making subclasses is using a plot space delegate. It has the following delegate methods:

-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(CPTNativeEvent *)event atPoint:(CGPoint)point;
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDraggedEvent:(CPTNativeEvent *)event atPoint:(CGPoint)point;
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceCancelledEvent:(CPTNativeEvent *)event;
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceUpEvent:(CPTNativeEvent *)event atPoint:(CGPoint)point;

Eric
Reply all
Reply to author
Forward
0 new messages