Re: sharedColorPanel question
Re: sharedColorPanel question
- Subject: Re: sharedColorPanel question
- From: Bob Smith <email@hidden>
- Date: Thu, 1 Mar 2007 18:32:39 -0800
If your object is in the responder chain you do not have to set
target and action, the color panel will send you -changeColor:
automatically when you are first responder. That way if some other
object becomes first responder you will not receive the color
changes. That is probably how most objects use the shared color
panel, hence others are not setting target and action when they call
up the panel so those still point to your object. Note your object
does not necessarily have to inherit from NSResponder to get the -
changeColor: message, it could implement this just by being a window
delegate.
Hope this helps!
Bob
On Mar 1, 2007, at 6:01 PM, Aaron Boothello wrote:
I use a contextual menu to bring up the shared color panel in order
to change a particular attribute in my application. the code is as
follows....
//-----------
- (IBAction)changeBackgroundColor:(id)sender
{
[[NSColorPanel sharedColorPanel] makeKeyAndOrderFront:self];
[[NSColorPanel sharedColorPanel] setTarget: self];
[[NSColorPanel sharedColorPanel] setAction:@selector
(changeColor:)];
}
-(void)changeColor:(id)sender
{
float colors[4];
colors[0]= [[[sender color] retain] redComponent];
colors[1]= [[[sender color] retain] greenComponent];
colors[2]= [[[sender color] retain] blueComponent];
colors[3]= [[[sender color] retain] alphaComponent];
}
//-------------
The problem arises when, in another part of the application, i use
a colorWell to change the color of another attribute. the target
and action remain unchanged(as above), and so these two different
colors change simultaneously. How do i correct this ?
Thanks,
Aaron
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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