objective-cmacoscocoanscursor

How to attach an object to the NSCursor? OSX


I want to attach a WebView to the cursor when the user hovers a button. And remove it when the mouse exits.
Even when the cursor moves inside the button I want to WebView to keep following the cursor.
Any ideas on how to perform this?

Here's an example on how it should be:
enter image description here


Solution

  • so you have a NSButton ... subclass THAT so you attach a view:

    @interface ButtonWithWebViewOnHover : NSButton
    @property(strong) WebView *webView;
    @end
    

    override mouseEntered and mouseExited there and toggle hidden

    ...... wait.... we seem to be reinventing the wheel


    use NSPopover (from apple directly, but not as graphically flexible as the next:)

    or MAAttachedWindow (http://mattgemmell.com/2007/10/03/maattachedwindow-nswindow-subclass/)