48 lines
996 B
Objective-C
48 lines
996 B
Objective-C
//
|
|
// SBTokenFieldCell.m
|
|
// Subler
|
|
//
|
|
// Created by Damiano Galassi on 10/11/16.
|
|
//
|
|
//
|
|
|
|
#import "SBTokenFieldCell.h"
|
|
|
|
@interface SBTokenFieldCell ()
|
|
|
|
@property (nonatomic) NSBackgroundStyle SB_originalBackgroundStyle;
|
|
|
|
@end
|
|
|
|
@implementation SBTokenFieldCell
|
|
|
|
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle
|
|
{
|
|
[super setBackgroundStyle:backgroundStyle];
|
|
if (backgroundStyle == NSBackgroundStyleDark) {
|
|
self.textColor = [NSColor controlHighlightColor];
|
|
}
|
|
else {
|
|
self.textColor = [NSColor controlTextColor];
|
|
}
|
|
}
|
|
|
|
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObj;
|
|
{
|
|
self.SB_originalBackgroundStyle = self.backgroundStyle;
|
|
|
|
self.backgroundStyle = NSBackgroundStyleLight;
|
|
self.drawsBackground = YES;
|
|
|
|
return [super setUpFieldEditorAttributes:textObj];
|
|
}
|
|
|
|
- (void)endEditing:(NSText *)textObj
|
|
{
|
|
[super endEditing:textObj];
|
|
self.drawsBackground = NO;
|
|
self.backgroundStyle = self.SB_originalBackgroundStyle;
|
|
}
|
|
|
|
@end
|