Re: Changing color in NSColorPanel without message
Re: Changing color in NSColorPanel without message
- Subject: Re: Changing color in NSColorPanel without message
- From: "email@hidden" <email@hidden>
- Date: Thu, 17 Jan 2013 08:08:30 +0000
On 17 Jan 2013, at 00:58, Melvin Walker <email@hidden> wrote:
> On Jan 16, 2013, at 4:45 PM, Andy Lee <email@hidden> wrote:
>> On Jan 16, 2013, at 6:09 PM, Melvin Walker <email@hidden> wrote:
>> [...]
>>>> When you select a color in the panel, NSColorPanel sends a changeColor: message to the first responder. It also sends its action message (set by setAction:) to its target object (set by setTarget:), provided that neither the action nor the target is nil. NSColorPanel also sends its action to its target whenever you select a color in the color panel.
>>>
>>> Yes, and this is the behavior I want to avoid.
>>>
>>> I can turn off the send-to-target behavior easily enough, but I can't turn off the send-a-changeColor:-message behavior.
>>
>> It looks like Apple really, really doesn't want you to do this. Every sneaky kludge I've thought of is thwarted by limitations of the API.
>>
>> This makes sense to me. I like that the standard color panel is always synced with the color of the first responder for a consistent user experience at all times in all apps.
>>
>> So we come to the old question: what are you really trying to do? If it doesn't reveal too much about your project, what are the meanings of the colors in question, and what use case do you have that warrants deviating from the standard behavior?
>
> I agree — it looks like setting the color is a round trip.
>
> We are doing some custom word processing and we wanted to be able to reflect the color of the text when the mouse is clicked in it. No NSTextView, so we don't get the behavior for free. I was hoping to change the code only in a small area, even if it meant something a bit kludgy, but it looks like a refactor-rewrite is in my future.
Thinking again. You could make NSColorPanel its own first responder when required. This might require subclassing to override NSColorPanel -changeColor:. Might be worth an experimental shot though.
Regards
Jonathan Mitchell
Mugginsoft LLP
_______________________________________________
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