// // KMCustomButtonPopMenuViewController.swift // PDF Reader Pro // // 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 // 某行对应的图片 @objc optional 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? // override var nibName: NSNib.Name? { // return "KMCustomButtonPopMenuViewController" // } @objc override func viewDidLoad() { super.viewDidLoad() // Do view setup here. var numberOfLine = 0 if let data = self.dataSources?.numberOfLine() { numberOfLine = data } if numberOfLine < 1 { return } var referenceView: NSView? = self.view for i in 0..