Initially, I was relying on the automatic change. Then I added code to update the cursor. I get the same results either way. I am subclassing NSRulerView here. A plain old NSRulerView exhibits the same behavior though. Here's what I have...
First, setup tracking area:
objective-c (void)setFrame:(NSRect)frame {
NSLog(@"setFrame");
[super setFrame:frame];
NSArrayNSTrackingArea * *oldAreas = self.trackingAreas;
NSLog(@"frame = %f, %f, %f, %f", self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
if (oldAreas.count 0) {
NSLog(@"removing %li tracking areas", oldAreas.count);
for (NSTrackingArea *ta in oldAreas) {
[self removeTrackingArea:ta];
}
}
self.mouseTrackingArea = [[NSTrackingArea alloc] initWithRect:self.frame
options:(NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow | NSTrackingCursorUpdate)
owner:self
userInfo:nil];
[self addTrackingArea:self.mouseTrackingArea];
}
Handle mouse events:
objective-c (void)mouseEntered:(NSEvent *)event {
NSLog(@"mouse entered");
[[NSCursor arrowCursor] set];
}
(void)cursorUpdate:(NSEvent *)event {
NSLog(@"cursorUpdate");
[[NSCursor arrowCursor] set];
}
Interestingly, the text "mouse entered" displays as soon as I move the mouse pointer into the targeted area, but the cursor change doesn't have any effect. Only when I enter the area from the right side, do I get the "cursorUpdate" message and that cursor change DOES take effect.