Post

Replies

Boosts

Views

Created

NSOutlineView.showHideButtonIdentifier custom button does not respect contentTintColor
I've been trying to provide NSOutlineView with custom disclosure button. Here is a simple NSButton subclass for that purpose: Swift final class AltDisclosureButton: NSButton {     override init(frame frameRect: NSRect) {         super.init(frame: frameRect)         setButtonType(.toggle)         isBordered = false     }     required init?(coder: NSCoder) {         fatalError("init(coder:) has not been implemented")     } } Then, in my NSOutlineView subclass, I do this: Swift override func makeView(withIdentifier identifier: NSUserInterfaceItemIdentifier, owner: Any?) - NSView? { var view = super.makeView(withIdentifier: identifier, owner: owner) if identifier == NSOutlineView.showHideButtonIdentifier, let button = view as? NSButton {         let customButton = AltDisclosureButton(frame: .zero)         customButton.target = button.target         customButton.action = button.action         customButton.identifier = identifier         let image = NSImage(systemSymbolName: "chevron.right.circle.fill", accessibilityDescription: "disclosure_indicator_button")!         customButton.image =  image         let altImage = NSImage(systemSymbolName: "chevron.down.circle.fill", accessibilityDescription: "disclosure_indicator_button_down")!         customButton.alternateImage = altImage         customButton.symbolConfiguration = NSImage.SymbolConfiguration(pointSize: 16, weight: .medium)         customButton.contentTintColor = NSColor.controlAccentColor view = customButton      } return view } It basically sets two SF Symbols images to image and alternateImage respectively. My problem is that there are only three NSButton.ButtonType values that work with button auto-rotate: .toggle, .switch, .radio, but none of them respect the contentTintColor -- the buttons are always gray.
Topic: UI Frameworks SubTopic: AppKit Tags:
0
0
576
Feb ’21