Question

Is there any way to detect last NSColorWell color selected?

So far i have create NSColorWell with action and target programmatically, So how many time i changed the color that method is called that much time. So i want to identified last selected color of NSColorWell.

No correct solution

OTHER TIPS

NSColorPanelResponderMethod category (informal protocol) on NSObject implements a method called changeColor:. So, you could override this method inside your class to detect the color changes for NSColorWell.

@interface MyClass:NSObject 
 @property(nonatomic, strong) NSColor *lastColor;
@end

@implementation MyClass
  - (void)colorChanged:(id)sender{
    NSLog(@"Last color %@", lastColor);
    NSColor *newColor = [sender color];
    NSLog(@"NSColorWell changed color %@", [sender color]);
  }
@end

If you want to be able to keep track of the last font, then you would create a property and everytime the font changes, assign the new font to the property. This way you will be able to keep track of the last font.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top