Custom NSCursor is not supported for all applications.

I wrote a Cocoa program to change the cursor after clicking a button. In particular, the cursor includes an image instead of a pointer. I installed it using the following commands:

NSImage *tmpImage = [NSImage imageNamed:@"pointer"]; NSCursor *pointer = [[NSCursor alloc] initWithImage:tmpImage hotSpot:NSMakePoint(10.0, 10.0)]; [pointer set]; 

This works and the cursor changes correctly. However, this change is not implemented for all applications. For example, when I switch to a Keynote presentation in a slide show, the cursor returns to the arrow. When I switch to full-screen PDF for presentation, the cursor changes to a hand (I believe that these are the default cursors set by the respective applications).

My question is: is there a way to override them and just keep my custom cursor for all applications? I would like to keep my modified cursor even during Keynote slideshow and full screen PDF viewing. Any ideas?

Thanks!

+4
source share
1 answer

It is not possible to change the cursor for other applications, at least without using the public API.

The only way to do this is to create a custom non-border window that will only display the cursor image, and then use the CoreGraphics API to hide the cursor and simply move the window as you move the mouse. This is similar to how Apple makes a large cursor, which you can enable in the settings of the Accessibility system.

0
source

All Articles