I'm attempting to add, remove, and re-add an instance of NSTrackingArea to a custom view. Adding works fine; removing works fine; but when I attempt to add it to the view again, the tracking area is not added.
Here's the code: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // myTrackingArea is declared as an instance variable of type NSTrackingArea * myTrackingArea = [[NSTrackingArea alloc] initWithRect:self.blueView.frame options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp) owner:self userInfo:nil]; } -(IBAction)addTrackingArea:(id)sender { [self.blueView addTrackingArea:myTrackingArea]; NSLog(@"%@", myTrackingArea); } -(IBAction)removeTrackingArea:(id)sender { [self.blueView removeTrackingArea:myTrackingArea]; } -(void)dealloc { [myTrackingArea release]; [super dealloc]; } The app launches and I click the button to target the addTrackingArea: action. It logs the following: NSTrackingArea 0x100526f80: rect={{20, 21}, {248, 320}}, owner=0x10012b730 userData=(null) NSTrackingMouseEnteredAndExited NSTrackingActiveInActiveApp pendingInstall notInstalled disabled The delegate now receives mouseEntered: and mouseExited: messages. Now I click the button to target the removeTrackingArea: action. The delegate stops receiving mouseEntered: and mouseExited:, as expected. Now I click the addTrackingArea: button. It logs the following: NSTrackingArea 0x100526f80: rect={{20, 21}, {248, 320}}, owner=0x10012b730 userData=(null) NSTrackingMouseEnteredAndExited NSTrackingActiveInActiveApp REMOVED pendingInstall notInstalled disabled (Note that curious 'REMOVED' in there.) The delegate still fails to receive mouseEntered: and mouseExited: messages. Can anyone explain why the tracking area can be added and removed but not re-added? Thanks in advance for any help. _______________________________________________ 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