Chapter 18. Tracking the Mouse

We’re in the home stretch! In this and the following three chapters, we’re going to fill in many of the standard Mac OS X features that you need to know in order to write commercial-level Cocoa applications.

Tracking the Mouse

Today’s users are so demanding! A few years ago you could write an application that would just sit there and wait for you to click a mouse button or press a key, but these days users expect your application to be always prepared to respond. When a user moves the mouse over something in an application’s window, if there is some way that your application can possibly convey information, the user expects it to happen.

What kind of information are we talking about? For example, if a user mouses over (i.e., lets the cursor hover over) the toolbar icons in the Mail application or the Colors panel, he will expect to get feedback about what clicking those icons will do. This is an example of Cocoa tool tips — something that is so simple to set with Interface Builder that we haven’t even bothered showing you how to do it. Can we arrange for even more sophisticated mouseover behavior within GraphPaper? Of course we can, and in this chapter we’ll show you how!

Tracking Rectangles

Until now, we’ve thought of Cocoa events as being in two categories: mouse events and keyboard events (although there are periodic and other types of events as well). Another way of classifying events is according to the type of programmatic gyrations that you ...

Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.