123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- //
- // AITipIconView.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2024/1/17.
- //
- import Cocoa
- @objcMembers class AITipIconView: NSView, NibLoadable {
-
- @IBOutlet weak var clickButton: KMButton!
- @IBOutlet weak var hoverImage: NSImageView!
-
- var clickHandle: ((_ view: AITipIconView) -> Void)?
- var rightClickHandle: ((_ view: AITipIconView) -> Void)?
-
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- @objc static func ocCreateFunction() -> AITipIconView{
- return AITipIconView.createFromNib()!
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- self.clickButton.mouseMoveCallback = {[unowned self] mouseEntered in
- if mouseEntered {
- self.hoverImage.image = NSImage(named: "pop-btn_hover")
- } else {
- self.hoverImage.image = NSImage(named: "pop-btn")
- }
- }
-
- let menu = NSMenu.init()
-
- let string = NSLocalizedString("Hide AI robot icon", comment: "")
- let menuItem = NSMenuItem.init(title: string, action: #selector(menuItemClick(_:)), keyEquivalent: "")
- menuItem.tag = 1000
- menu.addItem(menuItem)
-
- self.clickButton?.menu = menu
-
-
-
- }
-
-
- @objc func menuItemClick(_ item: NSMenuItem) {
- guard let callBack = self.rightClickHandle else {
- return
- }
- callBack(self)
- }
-
- //MARK: IBAction
- @IBAction func clickAction(_ sender: Any) {
- guard let callBack = self.clickHandle else {
- return
- }
- callBack(self)
-
- }
-
-
-
- }
|