Hacker News new | ask | show | jobs
by idlephysicist 891 days ago
Every now and then I dust off Xcode to try and build myself some (pretty simple) native macOS app – just for funsies.

For reference I am a backend dev at a SaaS company dealing primarily in Python & Go, doing HTTP/gRPC services and talking to databases.

Last night I attempted to make a program that would display an image and allow the user to click the image and then display the hex value of the colour under the cursor.

I wanted my application to use a crosshair cursor and after an hour of looking at the docs for NSCursor[1] and stackoverflow I just gave up.

I don't know how someone gets started in this ecosystem but I am sure once you know it this stuff is easy.

[1] https://developer.apple.com/documentation/appkit/nscursor

1 comments

It’s in the page you linked under set(). Combined with the properties at the top of the documentation page, to make the cursor a crosshair you’d call NSCursor.crosshair.set(), after which it’ll remain that cursor until something else changes it (so for instance, you’ll need to call it whenever the cursor enters the relevant view since e.g. crossing window borders will change the cursor).