KMMenuTableView.swift 524 B

1234567891011121314151617181920212223
  1. //
  2. // KMMenuTableView.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2022/12/16.
  6. //
  7. import Cocoa
  8. protocol KMMenuTableViewDelegate: NSObjectProtocol {
  9. func km_menu(for event: NSEvent) -> NSMenu?
  10. }
  11. class KMMenuTableView: NSTableView {
  12. weak var menuDelegate: KMMenuTableViewDelegate!
  13. override func menu(for event: NSEvent) -> NSMenu? {
  14. guard let myDelegate = self.menuDelegate else {
  15. return super.menu(for: event)
  16. }
  17. return myDelegate.km_menu(for: event)
  18. }
  19. }