Is there any way to handle multi-touch in a class which extend NSView? currently 1 touch with drag event is working now.
Asked
Active
Viewed 2,164 times
3
-
I have a class which extend NSView, and in this class, I could catch mouseDown, mouseUp, mouseDragged events, but I don't know how to count number of touch on the screen, if it is possible, I could handle it as multi-touch event. Anybody help me! – Son Nguyen Jun 29 '10 at 02:54
2 Answers
4
I know this is an old question, but if you want your NSView subclass to accept touch events (like in iOS, touchesBegan/Moved/Ended/Cancelled) and you are in OS X >= 10.6, you can put the following in your initWithFrame: method:
[self setAcceptsTouchEvents:YES];
[self setWantsRestingTouches:YES]; // for thumb
Then override the following methods:
- (void)touchesBeganWithEvent:(NSEvent *)event;
- (void)touchesMovedWithEvent:(NSEvent *)event;
- (void)touchesEndedWithEvent:(NSEvent *)event;
- (void)touchesCancelledWithEvent:(NSEvent *)event;
See the Cocoa Event Handling Guide for details

rich.e
- 3,660
- 4
- 28
- 44
-
If possible please help me out with a problem of mine. [Here](http://stackoverflow.com/questions/24734940/disable-user-interaction-for-nsimageview) is the question, thanks a lot :) – Eshwar Chaitanya Jul 14 '14 at 13:39
0
Actually, I am developing a feature which draw a chart and I used Core-Plot charting library, but the CPLayerHosting is extended from NSView so I don't know how to catch more than one touch points.
Very lucky for me that there are 2 CPLayerHosting class in Core-Plot project, another one is just used for IPhone and it is extended from UIView, so the problem is resolved! :)

Son Nguyen
- 3,481
- 4
- 33
- 47