0
votes

I have the following methods implemented for detecting finger up from trackpad or finger at stationary point. I am not getting how I could determine that fingers have been lifted from trackpad or the finger has stopped moving.

Let me know how could i determine the event for the same.

  • (void)touchesMovedWithEvent:(NSEvent *)event { NSLog(@"%s",_cmd); }

  • (void)touchesEndedWithEvent:(NSEvent *)event { NSLog(@"%s",_cmd);

}

  • (void)touchesCancelledWithEvent:(NSEvent *)event { NSLog(@"%s",_cmd);

}

1

1 Answers

0
votes

The methods you mentioned give you an NSEvent. Using this you can get the actual touches with $touchesMatchingPhase:inView:. After that you can e.g. loop trough them or just get the count (which you may compare to a previous count you have saved in an instance variable).

NSSet *touches = [[event touchesMatchingPhase:NSTouchPhaseAny inView:self];
NSInteger touchCount = [touches count];
for(NSTouch* touch in touches) {
   //do something e.g. check if they are still moving or not
}