问题
Is there a way to globally hide the mouse cursor for all apps in Cocoa (or Carbon)? Or at least replace it with something else?
EDIT: Thanks for the input guys, but turns out Daniel Jalkut found the solution a while ago :) http://lists.apple.com/archives/carbon-dev/2006/Jan/msg00555.html
回答1:
You are looking for CGDisplayHideCursor, which is part of the Quartz Display Services API.
回答2:
just add this to your code:
CGDisplayHideCursor (kCGNullDirectDisplay);
回答3:
Check out: http://developer.apple.com/legacy/mac/library/samplecode/CarbonCocoa_PictureCursor/listing2.html It's an old sample, but probably still works.
I expect that you're going to be limited to your application window, however. If you want to hide it for everyone you will probably have to make your window cover the screen.
Fun fact: The old toolbox function was simply "HideCursor()".
回答4:
No, I don't believe there's a way of doing what you want, short of showing a full screen window and then obscuring absolutely everything on the desktop. That would also prevent e.g. keystrokes being sent to the right application and the like.
来源:https://stackoverflow.com/questions/1412084/globally-hide-mouse-cursor-in-cocoa-carbon