why NSTrackingArea doesn't work?
why NSTrackingArea doesn't work?
- Subject: why NSTrackingArea doesn't work?
- From: Nick <email@hidden>
- Date: Thu, 23 Jun 2011 03:04:59 +0300
Hello
I need to watch when the mouse moved over the view (even when the app is not
'active'), and if this happens, to do something.
What I did:
in my custom subclassed view I defined:
-(id)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
NSLog(@"Init called!");
NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:[self
frame] options: (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways)
owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
return self;
}
-(void)mouseEntered:(NSEvent *)theEvent {
NSLog(@"mouse entered");
}
-(void)mouseExited:(NSEvent *)theEvent {
NSLog(@"mouse exited");
}
In terminal I get nothing - not even when the application is active and the
mouse is moved over it. The view is instantiated, and can be seen. The view
is added to the window's content view programmatically.
What could be wrong? Did I forget anything?
(Snow Leopard)
Thanks,
Nick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden