Search code examples
objective-cmacoscocoamouse-cursor

How to draw a highlight around mouse cursor


I'd like to be able to display a quick animated "flash" around the mouse cursor (similar to the effect in some screen-recording applications). What would be a good way to go about this?

My current idea is to display a temporary, floating, transparent window window under the mouse position, animate it, then hide it. But I'm wondering if there are any better suggestions?


Solution

  • This idea is your best bet. While it's not exactly what you're looking for, my JLNDragEffectManager (morphing images while dragging) demonstrates one approach to the "borderless window following the mouse".

    The difference is it looks like you're not interested merely in drag events, but rather "anywhere the mouse is." You can always get the current mouse location by asking NSEvent for the +mouseLocation (given in screen coordinates).