FoneMonkey

- (void) handleMonkeyTouchEvent:(NSSet*)touches withEvent:(UIEvent*)event;

The method implementation will typically:

  • Decide whether to record the event and if so
  • create a command corresponding to the event and then
  • record the command

For example, suppose you have a view called MyView that is a subclass of UIBotton and you want to generate an "DoubleTouch" command:

@implementation
MyView (FoneMonkey)

#import "FoneMonkeyAPI.h"
#import "MyView+FoneMonkey.h"
@implementation MyView (FoneMonkey)

- (NSString*) monkeyID {
    return self.myViewId ? self.myViewId :
        [super monkeyID];
}
- (void) handleMonkeyTouchEvent:(NSSet*)touches withEvent:(UIEvent*)event {
    UITouch* touch = [touches anyObject];
    if (touch.tapCount == 2) {
        [FoneMonkeyAPI record:self command:@"DoubleTouch" args:nil];
    } else {
        [super handleMonkeyTouchEvent:touches withEvent:event];
    }
}

 @end

handleMonkeyTouchEvent:withEvent is passed touch events for the associated UI component. By default, touches are passed only at the UITouchPhaseEnded phase. You can customize touch filtering by implementing:

- (BOOL) shouldRecordMonkeyTouch:(UITouch*)touch;

For example, if we want to record touch events continuously while the user's finger remains down on the view:

- (BOOL) shouldRecordMonkeyTouch(UITouch*) touch {

   return touch.phase == UITouchPhaseBegan || touch.phase == UITouchPhaseStationary;

}