views:

265

answers:

2

How would I go about programming a HUD type overlay in OSX. I want to be able to have an application that will display text at a certain point over a different application's window.

And thus if the (other applications) window moves the HUD part will stay at the same coordinate of the other window.

+1  A: 

For the window itself, use a borderless, transparent window (plenty of examples) with your own custom view into which to draw your overlaid elements.

For the "other applications' windows" part, there's no public API that's going to let you do this smoothly. You use Universal Access and its window location/navigation API, but it requires your users to turn on "Enable access for assistive devices" (I think it still can't be done programmatically). I don't believe it "lets you know" when a window moves, but I could be wrong. If it does, it'd likely be a one-shot "here's where I am now", so your overlay would likely not keep up. I also don't think it gives you the "window level" to allow you to make sure you're "above" any given window/sheet/palette.

The only other option (to move with other apps' windows) is a system-wide, invasive hack a la Application Enhancer (which is quite controversial). It's easy to get this wrong and destabilize a user's system (hence the controversy).

Joshua Nozzi
**Note:** I'm not interested in debating Application Enhancer. Not in the least.
Joshua Nozzi
A: 

You could use undocumented CoreGraphics Functions in order to track a window, see http://code.google.com/p/undocumented-goodness/source/browse/trunk/CoreGraphics/CGSPrivate.h

nob