开发者

How to efficiently set Cursor for an NSView?

开发者 https://www.devze.com 2023-01-15 16:37 出处:网络
I have an NSView that is drawing a collection of irregularly shaped (and overlapping) application managed objects: that obviously can\'t be described by efficiently using non overlapping rectangles.

I have an NSView that is drawing a collection of irregularly shaped (and overlapping) application managed objects: that obviously can't be described by efficiently using non overlapping rectangles.

I want to change the cursor when it it over one of these objects. The usual method seems to be to set up tracking rects in response to -(void)resetCursorRects, each associated with a different cursor, but I can't apply that to this situation.

I only know which object is top most under the cursor when processing -(void)mouseMoved:(NSEvent *)theEvent messages... so I need to change the cursor then.

Is this appropriate? When is NSView going to try and set the cursor to the usual arrow? I don't want to end up with a flickering c开发者_高级运维ursor because NSView is setting it to default on a different message.


Consider using tracking areas: Using Tracking-Area Objects. Particularly, NSTrackingCursorUpdate. This way, you can respond specifically to the individual types of tracking events. I think this helps avoid the situation you described.

0

精彩评论

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