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

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


  • Subject: Re: Unable to re-add tracking area after it's been removed
  • From: Gabriel Roth <email@hidden>
  • Date: Mon, 18 Jul 2011 21:43:54 -0400

Yes, that works—thanks very much.

If anyone can explain why my original version didn't
work, I'd appreciate it. My understanding was that the NSTrackingArea
object would be allocate, initialized, and assigned to an ivar in the
applicationDidFinishLaunching: method, and could then be added to and
removed from the view at will. But I'm inferring from your version
(and the fact that it works where mine fails) that something more
complicated happens when the tracking area is added to and removed
from the view.





On Mon, Jul 18, 2011 at 2:00 PM, Quincey Morris
<email@hidden> wrote:
> On Jul 18, 2011, at 04:59, Gabriel Roth wrote:
>
>> Thanks for the corrections. But changing the line in question to
>>
>>      myTrackingArea = [[NSTrackingArea alloc]
>> initWithRect:self.blueView.bounds
>> options:(NSTrackingMouseEnteredAndExited |
>> NSTrackingActiveInActiveApp | NSTrackingInVisibleRect ) owner:self
>> userInfo:nil];
>>
>> doesn't change the puzzling behavior when attempting to re-add the
>> tracking area.
>
> Try it this way:
>
> -(IBAction)addTrackingArea:(id)sender
> {
>        NSAssert (!myTrackingArea, @"Gotta remove the old one first");
>
>        myTrackingArea = [[NSTrackingArea alloc]
>                initWithRect:self.blueView.bounds
>                options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp | NSTrackingInVisibleRect )
>                owner:self
>                userInfo:nil];
>
>        [self.blueView addTrackingArea:myTrackingArea];
> }
>
> -(IBAction)removeTrackingArea:(id)sender
> {
>        if (!myTrackingArea)
>                return;
>
>        [self.blueView removeTrackingArea:myTrackingArea];
>        myTrackingArea = nil;
> }
>
>
>
_______________________________________________

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

References: 
 >Unable to re-add tracking area after it's been removed (From: Gabriel Roth <email@hidden>)
 >Re: Unable to re-add tracking area after it's been removed (From: Quincey Morris <email@hidden>)
 >Re: Unable to re-add tracking area after it's been removed (From: Gabriel Roth <email@hidden>)
 >Re: Unable to re-add tracking area after it's been removed (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: NSArrayController nib binding vs code binding
  • Next by Date: Re: NSArrayController nib binding vs code binding
  • Previous by thread: Re: Unable to re-add tracking area after it's been removed
  • Next by thread: NSTextView won't deallocate
  • Index(es):
    • Date
    • Thread