2

I previously asked a question about changing the cursor system-wide on OSX. I used NSCursor to change the cursor, but the effects are only as long as the application is active. When another application becomes active, the custom cursor is lost.

Here is a related, more general question. How can you write an application to have system-wife effects? For example drawing an image on-screen even when your application is not active, and something else is?

I understand I probably need to go at a lower level than the Cocoa APIs. I just cannot figure out where to start looking? Any specific Carbon APIs that I need to be looking at? Or even lower?

Any pointers would be appreciated! If you specifically know how to change the cursor system-wide or how to draw an image and move it around (no matter what application is active), that would solve my current problem as well! Can I write an application that can achieve this when its installed on the system?

Thanks!

AJJ
  • 105
  • 1
  • 2
  • 5

2 Answers2

2

You can achieve the effect you want, but not the way you're thinking about doing it.

You say,

I am writing a presentation aid application that shows the equivalent of the "laser pointer" on screen, programmatically. My first idea was to use the mouse cursor itself as the pointer, and change its appearance as a red circle.

Then fake that. Create an application, perhaps of type LSUIElement, perhaps not, depending on the behavior you want. Create a borderless window (type NSBorderlessWindowMask) and fill it with a clear color. Set its window level high enough so that it floats over everything (using -[NSWindow setLevel:], though I can't think of what the best level would be off-hand), and draw into it.

It's true that you cannot set the cursor when you are not the foremost app. It's true that you cannot just scribble on the screen. But you can get the same effects if you're clever.

Avi
  • 573
  • 4
  • 4
0

This behaviour is not provided by any APIs on Mac OS X. You would have to modify the resource files in the OS, and that's a very dangerous operation that could brick the target computer. You have to know what you're doing.

Are you trying to implement a theming app or something like that? What's your goal? If you tell us what you are trying to do, we may be able to suggest alternate approaches.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
  • Here is a simple instance of one thing I am trying to do. I am writing a presentation aid application that shows the equivalent of the "laser pointer" on screen, programmatically. My first idea was to use the mouse cursor itself as the pointer, and change its appearance as a red circle. If that's not possible as you say, I want to draw a red circle on the screen and control it programmatically, but it should be able to show even when the application itself is not active (in this case, when the presentation is running in full-screen). Thanks! – AJJ Aug 17 '11 at 07:51
  • I think you may have to reconsider what you're doing. Laser pointers are effective because the dot they produce is much brighter than the image projected and so stands out above it. Any red dot on the screen will be only as bright as the projection, and so will not be instantly visible. – Jonathan Grynspan Aug 17 '11 at 11:30