• 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: How to get NSColorPanel's target?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get NSColorPanel's target?


  • Subject: Re: How to get NSColorPanel's target?
  • From: Neil Earnshaw <email@hidden>
  • Date: Thu, 21 Aug 2003 14:21:49 +0100

The color panel can work without a target. If its target hasn't been set then it checks to see if the first responder implements changeColor:

I've got an app delegate method that opens it in response to a MainMenu->Window->Show Color Panel menu item:

-(IBAction)showColorPanel:(id)sender
{
[[NSColorPanel sharedColorPanel] orderFront:self];
}

and a window controller that implements changeColor:

-(IBAction)changeColor:(id)sender
{
if ( 0 < [_selectedDKNodes count] ) {
int i;
for ( i = 0 ; i < [_selectedDKNodes count] ; i++ ) {
[[_selectedDKNodes objectAtIndex:i] setColor:[sender color]];
}
}
if ( ! ([_selectedDKNodes count] || _selectedDKPath) ) {
[_dkModel setColor:[sender color]];
}
}

As long as its window is the active one, the window controller will get the message. There's no need to set target or release anything. Its all automatic.

Hope this helps,

-Neil


On Tuesday, August 19, 2003, at 04:37 AM, Keith Renz wrote:

I'm setting NSColorPanel's shared instance's target to a custom view (no color well is being used). When I deallocate the view, I would like to decouple it from the color panel if it is the color panel's target by resetting the color panel's target and action to nil. I would like to ask the color panel what its target is, but there's no method to do so. I can get at the color panel's private _target instance variable with key value coding ([colorPanel valueForKey:@"target"]), but this isn't really kosher. Is there a better way to do this without manually keeping track of the color panel's target?

Thanks,

Keith
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


Neil Earnshaw
Consultant Software Engineer
Object Software Engineers Ltd
email@hidden
Tel : 01747 854 852
Mbl : 07870 209 102
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >How to get NSColorPanel's target? (From: Keith Renz <email@hidden>)

  • Prev by Date: Automating PackageMaker?
  • Next by Date: Re: Diff-ing two executables?
  • Previous by thread: How to get NSColorPanel's target?
  • Next by thread: Re: How to get NSColorPanel's target?
  • Index(es):
    • Date
    • Thread