I have an NSButton set as a checkbox with the following code on Catalina (Mojave is fine):
let checkbox = NSButton(frame: NSRect(x: 0, y: 0, width: 200, height: 32))
checkbox.setButtonType(.switch)
checkbox.title = "Sustain"
checkbox.state = .off
self.view.addSubview(checkbox)
It looks fine when I load the app
But as soon as I check it, the tick mark that I expect to be there isn't there
If I load up the visual hierarchy debugger I can see it fine, I've tried putting this code straight onto a new app and it works, but in my app it's hidden, almost like something is overriding it...any help appreciated
It also happens on NSPopUpButtons....no borders :-s
Update: 14th October 2019
As mentioned in the comments, it appears it's an Xcode 11 bug, Xcode 10.3 renders the button correctly on Catalina.
Update: 10th October 2019
Weirdly, creating a subclass and setting a CIFilter shows the checkbox item, you only have to do this to one NSButton, then suddenly, all the rest work :-s
import AppKit
class Checkbox : NSButton {
init() {
super.init(frame: .zero)
addFilter()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
addFilter()
}
// add random cifilter
func addFilter() {
let colorFilter = CIFilter(name: "CIFalseColor")!
colorFilter.setDefaults()
colorFilter.setValue(CIColor(cgColor: NSColor.black.cgColor), forKey: "inputColor0")
colorFilter.setValue(CIColor(cgColor: NSColor.white.cgColor), forKey: "inputColor1")
self.contentFilters = [colorFilter]
}
}
Doing the same for the dropdown works, but it's invisible until you click it...starting to feel like a Catalina bug