Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocoa application changing mouse cursor?

I have a cocoa application that has a view which is clickable. I cannot figure out how to change the cursor when the user mouses over it. I want to do this so that the user knows that they can click on it. I know this should be very simple, but I have not been able to find anything via google or stackoverflow. Anyone have any ideas?

like image 398
Kyle Avatar asked Feb 27 '11 20:02

Kyle


2 Answers

So, not this?

Cocoa: change cursor when it's over an NSButton

[yourButton addCursorRect:[yourButton bounds] cursor:[theCursorYouWant]];

(Quote from Mark)

like image 131
Dbz Avatar answered Nov 15 '22 07:11

Dbz


This is a relatively simple thing to do using NSView's tracking areas methods in conjunction with the NSCursor class to change the cursor. In general, the way you do this is set up a tracking area for your view, and when you get mouseEntered and mouseExited updates from the tracking area, you can update the cursor.

Check out the NSView Class Reference and the NSCursor Class Reference for more information.

like image 28
Itai Ferber Avatar answered Nov 15 '22 09:11

Itai Ferber