I have strange things happening when attempting to create a NSColorPanel in Swift
here is a very MINIMAL test project
import Cocoa
@main
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
let cp = NSColorPanel.shared
cp.setTarget(self)
cp.setAction(#selector(colorDidChange(_:)))
cp.makeKeyAndOrderFront(self)
cp.isContinuous = true
cp.showsAlpha = false
cp.color = NSColor.green
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
@objc private func colorDidChange(_ sender: Any?) {
if let cp = sender as? NSColorPanel {
print(cp.color)
}
}
}
this is the display I get
anytime I change the code above (like setting a new default color)… the next run has MORE boxes at the bottom. It just gets taller and taller… I have spent all day looking for anything that might lend a clue.
Note : if you create a project and add this code… it will “probably” be ok… until you change something