KMBotaTableRowView.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // KMBotaTableRowView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/11/28.
  6. //
  7. import Cocoa
  8. class KMBotaTableRowView: NSTableRowView {
  9. var selectCallback: ((KMBotaTableRowView)->Void)?
  10. convenience init() {
  11. self.init(frame: .zero)
  12. self.addTrackingArea()
  13. }
  14. override func draw(_ dirtyRect: NSRect) {
  15. super.draw(dirtyRect)
  16. // Drawing code here.
  17. }
  18. func addTrackingArea() {
  19. let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .inVisibleRect, .activeAlways, .mouseMoved], owner: self, userInfo: nil)
  20. self.addTrackingArea(trackingArea)
  21. }
  22. override func drawSelection(in dirtyRect: NSRect) {
  23. let selectionRect = self.bounds
  24. KMAppearance.Status.selColor().setFill()
  25. let selectionPath = NSBezierPath(roundedRect: selectionRect, xRadius: 0, yRadius: 0)
  26. selectionRect.fill()
  27. }
  28. override var isSelected: Bool {
  29. get {
  30. return super.isSelected
  31. }
  32. set {
  33. super.isSelected = newValue
  34. self.selectCallback?(self)
  35. }
  36. }
  37. }