tags:

views:

67

answers:

2

I am writing a custom NSView subclass. I have several instances of this class in my window, most of which are rotated by calling NSView's setFrameRotation method. I also need to change the cursor when over a rectangular region of this view.

The documentation for NSView's addCursorRect method contains the following oblique warning:

Cursor rectangles aren’t subject to clipping by superviews, nor are they intended for use with rotated views.

Well, shucks. But, I'd sure love to use them since they're a much nicer solution than the hacks I'd otherwise have to use. And, you know what? I tried it and it seems to work fine. Nevertheless, that warning scares me; I'm worried that the devil will come to collect his due at some point down the road. Therefore, my question is this: does anyone know why cursor rectangles aren't intended for use with rotated views?

+1  A: 

Yeah, it figures that right after posting my question, the answer would occur to me. It appears as though the hit detection employed by cursor rects operates on simple rectangles only; therefore, if a view with a cursor rect is rotated, the actual cursor rect used will be the smallest rectangle that completely encloses the rotated original rect.

However, I'm leaving this open in case there are other undesirable side effects I'm not seeing.

Ryan Ballantyne
+1  A: 

Although I haven't tried this myself, it looks like 10.5 added a new way to do this with Tracking Area Objects and it doesn't appear to have the limitation that old school cursor rects have.

Doug Richardson