0

It seems the default appearance of an NSAlert is less than ideal. For example when I click a checkbox, the checkbox disappears, and the focused button has white text.

[Edit] I should mention that this is a Metal app.

Here is the code for creating the NSAlert (using SnapKit for constraints):

                let aview = NSView(frame: NSRect(x: 0, y: 0, width: 150, height: 70))
                let btn = NSButton(checkboxWithTitle: "Sound", target: nil, action: nil)
                let btn1 = NSButton(checkboxWithTitle: "Music", target: self, action: #selector(handleMusicToggle(_:)))
                aview.addSubview(btn)
                aview.addSubview(btn1)

                btn.snp.makeConstraints { (make) in
                    make.leading.equalToSuperview()
                    make.top.bottom.equalToSuperview()
                }
                btn1.snp.makeConstraints { (make) in
                    make.leading.equalTo(btn.snp.trailing)
                    make.trailing.equalToSuperview()
                    make.top.bottom.equalToSuperview()
                }

                let alert = NSAlert()
                alert.messageText = "PAUSED"
                alert.informativeText = "BLOKKIT is paused"
                alert.alertStyle = .warning
                alert.accessoryView = aview
                alert.addButton(withTitle: "RESUME")
                alert.addButton(withTitle: "QUIT")
                let response = alert.runModal()

Here is a screenshot of how the NSAlert looks: enter image description here

Bret
  • 883
  • 1
  • 9
  • 18
  • I tested on Xcode 11.2 beta 2 without using sip but creating directly the btn and btn1 frames. I do not get the problem, Music check box is OK. And RESUME shows on a blue background.Try removing sap and set the frames manually, just for confirmation. – claude31 Nov 10 '19 at 22:03
  • 1
    Duplicate of [NSButton in Catalina has no selected state](https://stackoverflow.com/questions/58291431/nsbutton-in-catalina-has-no-selected-state) – Willeke Nov 11 '19 at 02:20
  • I tried on the 11.2.1 GM seed. Same appearance. – Bret Nov 11 '19 at 04:11

1 Answers1

0

For information, here is what I get:

enter image description here

claude31
  • 874
  • 6
  • 8
  • I've found that the NSAlert looks fine when creating the project using the basic MacOS template but it looks like my screenshot when you create the project using the Cross-Platform Game template. – Bret Nov 11 '19 at 17:40