Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Custom text colors don't automagically invert.
- class TableViewTextFieldCell: NSTextFieldCell {
- private var previousTextColor: NSColor?
- override var backgroundStyle: NSView.BackgroundStyle {
- get {
- return super.backgroundStyle
- }
- set(newBackgroundStyle) {
- // If we are going to light because we are selected, save off the old color so we can restore it
- if self.backgroundStyle == .light && newBackgroundStyle == .dark {
- previousTextColor = self.textColor
- self.textColor = NSColor.white // or a named color?
- } else if self.backgroundStyle == .dark && newBackgroundStyle == .light {
- if previousTextColor != nil {
- self.textColor = previousTextColor
- previousTextColor = nil
- }
- }
- super.backgroundStyle = newBackgroundStyle
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement