shakthi
shakthi

Reputation: 1657

How to use NSCursor to display custom cursor

I am trying to use custom cursor in my game using nscursor. I use following code


//While initializing openglview 
    mCustomCursor = [[NSCursor alloc] initWithImage:image hotSpot:NSZeroPoint];
    [image release];
[mCustomCursor set]

I am setting cursor rect in resetcursorrect method


- (void)resetCursorRects
{

    [self  addCursorRect:currentViewPortRect cursor:[NSCursor currentCursor]];

}

Custom cursor appears, It is not consistent, at times it switches back to system cursor (for alerts), some times it comes back and sometime not. It is so confusing. I am not sure if I should use 'setOnMouseEntered', 'pop'. What is the standard way to use nscursor and change it dynamically.

Upvotes: 2

Views: 4624

Answers (1)

Peter Hosey
Peter Hosey

Reputation: 96373

You're changing the cursor to the current cursor, which isn't changing it at all. To display your own custom cursor, you must pass your custom cursor when creating the cursor rect.

Upvotes: 3

Related Questions