KMPopupMenuObject.swift 614 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // KMPopupMenuObject.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/11/21.
  6. //
  7. import Cocoa
  8. class KMPopupMenuObject: NSObject {
  9. var menuTag: Int = 0
  10. var enterControllerCallback: ((_ isEnter: Bool)->Void)?
  11. }
  12. extension KMPopupMenuObject: NSMenuDelegate {
  13. func menuWillOpen(_ menu: NSMenu) {
  14. guard let callback = self.enterControllerCallback else {
  15. return
  16. }
  17. callback(true)
  18. }
  19. func menuDidClose(_ menu: NSMenu) {
  20. guard let callback = self.enterControllerCallback else {
  21. return
  22. }
  23. callback(false)
  24. }
  25. }