O'Reilly logo

Cocoa Programming for Mac OS X, Third Edition by Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 18. Images and Mouse Events

In the previous chapter, you drew lines connecting random points. A more interesting application would have been to write a drawing application. To write this sort of application, you will need to be able to get and handle mouse events.

NSResponder

NSView inherits from NSResponder. All the event-handling methods are declared in NSResponder. We discuss keyboard events in the next chapter. For now, we are interested only in mouse events. NSResponder declares these methods:

    - (void)mouseDown:(NSEvent *)theEvent;
    - (void)rightMouseDown:(NSEvent *)theEvent;
    - (void)otherMouseDown:(NSEvent *)theEvent;

    - (void)mouseUp:(NSEvent *)theEvent;
    - (void)rightMouseUp:(NSEvent *)theEvent;
    - (void)otherMouseUp:(NSEvent *)theEvent; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required