• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
why NSTrackingArea doesn't work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: why NSTrackingArea doesn't work?
      • From: Conrad Shultz <email@hidden>
  • Prev by Date: Re: tooltips not firing on first try
  • Next by Date: Re: why NSTrackingArea doesn't work?
  • Previous by thread: Re: constrained window resizing
  • Next by thread: Re: why NSTrackingArea doesn't work?
  • Index(es):
    • Date
    • Thread