3

I have difficulties to understand what happens when one overrides mouse events in an NSView.

In the following sample both methods are called by the Cocoa framework:

- (void)mouseDown:(NSEvent *)theEvent {
  NSLog(@"mouseDown");
}

- (void)mouseDragged:(NSEvent *)theEvent {
  NSLog(@"mouseDragged");
}

When I add [super mouseDown:theEvent] to the mouseDown: method the mouseDragged: method is not called by the Cocoa framework anymore:

- (void)mouseDown:(NSEvent *)theEvent {
  NSLog(@"mouseDown");
  [super mouseDown:theEvent];
}

- (void)mouseDragged:(NSEvent *)theEvent {
  NSLog(@"mouseDragged");
}

Why is this? How can I call the standard mouseDown behavior of the Cocoa framework so that mouseDragged: gets called?

  • 1
    I found a way to achieve, what I wanted to do by applying the "Mouse-Tracking Loop Approach" mentioned in Apple's Cocoa Event Handling Guide (handling the dragging in the mouseDown: event). Yet I still down't know how to intercept mouseDown: and still get mouseDrag: called by Cocoa for future cases. –  Aug 03 '13 at 19:08

0 Answers0