Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I did this in a previous project by using a matrix of custom <code>buttonCells</code>. I added a <code>backgroundColor</code> property to the button cell, so I could get a colored background on a cell with no border (which isn't possible with the standard cell types). Here is the subclass of <code>NSButtonCell</code> that I made:</p> <pre><code>@interface RDButtonCell : NSButtonCell &lt;NSCoding&gt; @property (retain) NSColor *selectedColor; @property (retain) NSColor *backgroundColor; -(id)initWithRGBAlpha:(NSArray *)rgbAlpha; @implementation RDButtonCell -(id)initWithRGBAlpha:(NSArray *)rgbAlpha { if (self = [super init]) { NSColor *color = [NSColor colorWithCalibratedRed:[rgbAlpha[0]doubleValue] green:[rgbAlpha[1]doubleValue] blue:[rgbAlpha[2]doubleValue] alpha:[rgbAlpha[3]doubleValue]]; [self setBackgroundColor:color]; [self setTitle:@""]; [self setBordered:NO]; [self setTag:0]; } return self; } -(void) setState:(NSInteger)value { if (value == 1) { self.backgroundColor = self.selectedColor; [super setState:value]; }else { self.backgroundColor = self.backgroundColor; [super setState:value]; } } -(void) setBackgroundColor:(NSColor *)color { _backgroundColor = color; _selectedColor = [color colorWithAlphaComponent:.75]; } - (void)encodeWithCoder:(NSCoder *)encoder { [super encodeWithCoder:encoder]; [encoder encodeObject:_backgroundColor forKey:@"bColor"]; } - (id)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; _backgroundColor = [decoder decodeObjectForKey:@"bColor"]; return self; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload