How to change the mouse cursor in Objective-C

╄→尐↘猪︶ㄣ 提交于 2019-12-01 14:41:54

There's a handy NSCursor class for handling cursor appearance. If one of the built-in cursors doesn't look how you need it to, you can initialize a new NSCursor with an NSImage and -set it to be the active cursor.

If the drawing area is rectangular(NSTracking Areas are always rectangular) :- Use the mouseEntered,mouse Exited methods of NSTrackingArea to track and change the mouse cursor.The mouse cursor could be changed using NSCursor class.

If the tracking area is not rectangular then make a bigger rectangular tracking area enclosing the whole drawing region and then track the mouseMoved events inside the tracking area to set the cursor appropriately . Refer to apple documentation for more details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!