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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to