// // KMCustomButtonPopMenuViewController.swift // PDF Master // // Created by wanjun on 2023/10/7. // import Cocoa import Masonry @objc protocol KMCustomButtonPopMenuViewControllerDataSources: AnyObject { // pop框有多少行 func numberOfLine() -> Int // pop框某行显示的文字 func stringForLine(at index: Int) -> String? // 某行是否需要下划线 func needInsertSeperateLine(at index: Int) -> Bool // 某行是否需要选取 func needHightLightLine(at index: Int) -> Bool // 某行对应的图片 func imageForLine(at index: Int) -> NSImage? // 某行是否可用 func itemEnable(at index: Int) -> Bool } @objc protocol KMCustomButtonPopMenuViewControllerDelegate: AnyObject { func customViewButtonPopDidSelectIndex(_ index: Int) } @objc class KMCustomButtonPopMenuViewController: NSViewController { weak var dataSources: KMCustomButtonPopMenuViewControllerDataSources? weak var delegate: KMCustomButtonPopMenuViewControllerDelegate? @objc override func viewDidLoad() { super.viewDidLoad() // Do view setup here. var numberOfLine = 0 if self.responds(to: Selector.init(("numberOfLine"))) { numberOfLine = self.dataSources!.numberOfLine() } if numberOfLine < 1 { return } var referenceView: NSView? = self.view for i in 0..