On Jan 17, 2013, at 4:45 PM, Andy Lee <ag...@mac.com> wrote: > On Jan 17, 2013, at 2:53 PM, Ken Thomases <k...@codeweavers.com> wrote: > >> On Jan 16, 2013, at 2:47 PM, Melvin Walker wrote: >> >>> Is it possible to programmatically change color (using -setColor:) in >>> NSColorPanel without it sending a changeColor: message to the first >>> responder? >>> >>> We'd like it to just reflect a color change without telling the responder >>> chain about it. >> >> I believe that NSColorPanel dispatches the -changeColor: action method using >> -[NSApplication sendAction:to:from:]. Therefore, you should be able to use >> a custom application object (subclass of NSApplication) with an override of >> that method which short-circuits for that selector (perhaps only under >> certain circumstances). > > Ooh! I tried overriding targetForAction:to:from: and targetForAction:, > assuming they were getting called. But I didn't think to try > sendAction:to:from:. Will give that a shot.
Didn't work. > Note that even if this works, it doesn't suppress the > NSColorPanelColorDidChangeNotification, so there may still be unwanted side > effects of setting the color panel's color. NSColorWell doesn't implement changeColor:, yet when a color well is first responder it changes to match the color panel. I tried a subclass of NSColorWell that implements changeColor: as a no-op. The method got called, but the color well changed color anyway. So at least for color wells, changeColor: isn't the mechanism causing them to change color when you set the color panel's color. I would think they must be listening for the notification -- but I tried telling the color well to stop observing that notification and it *still* changed color. I bet behind the scenes a different mechanism is being used to update color wells than is provided to us devs in the API. Not target-action (I set the target to nil), not changeColor:, not the notification -- I even checked whether the color well is using KVO on the @"color" property of the color panel. If none of these mechanisms, I wonder how. Apple *really* doesn't want us to do this. --Andy _______________________________________________ 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