Здравствуйте! Как поменять поведение строки таблицы, которая унаследована от класса NSTableRowView, при выделении?
Я переопределил метод override func drawSelection(in dirtyRect: NSRect), но он не вызывается. Здесь полный текст класса строки:
import Foundation
import Cocoa
class CategoryRow: NSTableRowView {
let TAG = "CategoryRow"
@IBOutlet weak var imageView: NSImageView!
@IBOutlet weak var textField: NSTextField!
@IBOutlet weak var countTextField: NSTextField!
@IBOutlet var view: NSView!
var nibName = "CategoryRow"
override func drawSelection(in dirtyRect: NSRect) {
super.drawSelection(in: dirtyRect)
print("class \(TAG) -> func drawSelection -> isSelected = \(isSelected)")
}
override func drawBackground(in dirtyRect: NSRect) {
super.drawBackground(in: dirtyRect)
print("class \(TAG) -> func drawBackground -> isSelected = \(isSelected)")
}
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
Bundle.main.loadNibNamed(NSNib.Name(rawValue: nibName),owner:self,topLevelObjects: nil)
let contentFrame = NSMakeRect(0, 0, frame.size.width, frame.size.height)
self.view.frame = contentFrame
self.addSubview(self.view)
}
required init?(coder decoder: NSCoder) {
super.init(coder: decoder)
Bundle.main.loadNibNamed(NSNib.Name(rawValue: nibName),owner:self,topLevelObjects: nil)
let contentFrame = NSMakeRect(0, 0, self.frame.size.width, self.frame.size.height)
self.view?.frame = contentFrame
self.addSubview(self.view!)
}
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
print("class \(TAG) -> func draw")
}