0

Can't figure out how to handle mouse move over NSCell (or NSTextAttachmentCell). Is it possible ?

dmitrynikolaev
  • 8,994
  • 4
  • 30
  • 45

1 Answers1

1

You can add a tracking area in the view that contains the cell and implement mouseEntered: and mouseExited: (and mouseMoved if you need that also) in that view. Here is an example where I added a tracking area one a button (button is the IBOutlet for the button). I added this code in the view's awakeFromNib method:

NSTrackingArea *buttonArea = [[NSTrackingArea alloc] initWithRect:self.button.frame options:NSTrackingMouseEnteredAndExited|NSTrackingMouseMoved|NSTrackingActiveInActiveApp owner:self userInfo:nil];
    [self addTrackingArea:buttonArea];

This will cause the view to receive mouseEntered, mouseMoved, and mouseExited messages when the cursor enters the frame of the button.

rdelmar
  • 103,982
  • 12
  • 207
  • 218