mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
21 lines
484 B
Swift
21 lines
484 B
Swift
//
|
|
// NSMenu+AssociatedObject.swift
|
|
// DynamicIsland
|
|
//
|
|
// Retains menu action targets using associated objects.
|
|
//
|
|
|
|
import AppKit
|
|
|
|
private final class MenuActionBox: NSObject {
|
|
let target: AnyObject
|
|
init(target: AnyObject) { self.target = target }
|
|
}
|
|
|
|
extension NSMenu {
|
|
private static let retainedAction = AssociatedObject<MenuActionBox>()
|
|
|
|
func retainActionTarget(_ target: AnyObject) {
|
|
NSMenu.retainedAction[self] = MenuActionBox(target: target)
|
|
}
|
|
}
|