• 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
Unable to re-add tracking area after it's been removed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unable to re-add tracking area after it's been removed


  • Subject: Unable to re-add tracking area after it's been removed
  • From: Gabriel Roth <email@hidden>
  • Date: Sun, 17 Jul 2011 15:22:19 -0400

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 (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: Unable to re-add tracking area after it's been removed
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Need help debugging this
  • Next by Date: NSTextView won't deallocate
  • Previous by thread: Re: Need help debugging this
  • Next by thread: Re: Unable to re-add tracking area after it's been removed
  • Index(es):
    • Date
    • Thread