开发者

How to use NSCursor to display custom cursor

开发者 https://www.devze.com 2023-04-09 20:29 出处:网络
I am trying to use custom cursor in my game using nscursor.I use following code //While initializing openglview

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消