resetCursorRects not working (new cursor only flashes as mouse enters)

| | August 4, 2015

I’m creating a custom view that needs a special cursor (instead of the usual arrow).
I’m using the resetCursorRects to setup the new cursor and its area, but the new cursor only appears briefly when the mouse enters the rect area, returning to arrow.

To check things better, I’ve created a new project, create a new custom view (based on NSView), add it to the window, but the problem remains.
The custom view code:

#import "TestView.h"

@implementation TestView

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];

    [[NSColor redColor]set];
    [NSBezierPath fillRect:self.bounds];

    [self addCursorRect:NSMakeRect(2, 2, 40, 40) cursor:[NSCursor openHandCursor]];


I’ve tried things like [super resetCursorRects] or [self discardCursorRects] before the addCursorRect, but nothings happens. Am I doing anything wrong?

Leave a Reply