Can't figure out how to handle mouse move over NSCell
(or NSTextAttachmentCell
). Is it possible ?
Asked
Active
Viewed 1,139 times
0

dmitrynikolaev
- 8,994
- 4
- 30
- 45
1 Answers
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
-
Thank you! Seems that this is only possible workaround to track nscell area. – dmitrynikolaev May 01 '12 at 06:50
-
What about a IKImageBrowserCell which is not inheriting from a NSCell, but NSObject ? thanks – aneuryzm Mar 22 '13 at 12:27
-
@Patrick, sorry, I don't know anything about IKImageBrowserCell. – rdelmar Mar 22 '13 at 15:27