Is there a way, by notification or else, to detect that a NSColorWell’s color has been changed via the color picker?
There is no basic -controlDidChange_(aNotification) for NSControl, only for text fields. The NSColorWell is KVO-compliant, so it can send automatic key-value change notification. Does it mean the NSColorWell’s value must be declared as a property and bound in IB?
Or is there an other way to it, by sending the NSColorWell a selector address?
I wrote this little bit of code to test binding of colors to color wells, and it includes a method, “click” that is called whenever you click on a new color in the color picker or drag the slider in the color picker panel. “click” is just the action method for the color wells (I have three of them, with their value bound to gColorList.color0, gColorList.color1, gColorList.color2).
property parent : class "NSObject"
property gColorList : missing value
on applicationWillFinishLaunching_(aNotification)
set my gColorList to current application's NSMutableDictionary's alloc()'s init()
gColorList's setValue_forKey_(current application's NSColor's colorWithCalibratedRed_green_blue_alpha_(1, 1, 0, 1), "color0")
gColorList's setValue_forKey_(current application's NSColor's colorWithCalibratedRed_green_blue_alpha_(1, 0, 1, 1), "color1")
gColorList's setValue_forKey_(current application's NSColor's colorWithCalibratedRed_green_blue_alpha_(0, 1, 1, 1), "color2")
end applicationWillFinishLaunching_
on click_(sender) --IBAction for the 3 color wells
log sender's |color|()
log gColorList
end click_
The message does not depend to the fact that colorWells are bound, does it? There is no “myColorWell’s setAction” in your code, so the message should be passed when the color well is clicked. Strange.
No, it doesn’t depend on the bindings – I tried it with a new color well that isn’t bound to anything. I connected “click” to the color well just like any other action method, by dragging.