On 17 Jan 2013, at 00:58, Melvin Walker <mwal...@mac.com> wrote:

> On Jan 16, 2013, at 4:45 PM, Andy Lee <ag...@mac.com> wrote:
>> On Jan 16, 2013, at 6:09 PM, Melvin Walker <mwal...@mac.com> 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.

The refactor could be fairly simple.
A category method on NSColorPanel could be used to insert a filter into the 
responder chain as and when required before displaying the panel.
The filter could then divert the change request locally as required.

Regards

Jonathan Mitchell
Mugginsoft LLP


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to