So new to programming Mac apps and am running into a problem. On my NSComboBoxes they do not highlight the currently selected item when reopening the dropdown. I might just be blind or maybe the default highlight color is transparent. I just don't know. See the below image for what I am getting.
At this point I have very little code written and everything is being done on my Storyboard. Just a little confused why it isn't doing something that should be quite simple. Guess I spent too much time in iOS land.
So decided to recreate the entire project as just one single sample NSCombobox to demonstrate that this happens on something simple for me while running Xcode 9.2.
The only outlet I have hooked up are the delegates and datasource for the NSComboBox. And the only settings changed on the NSComboBox are to enable datasource, and to change the behavior toe Selectable. The code to run this combo is just as simple:
import Cocoa
class ViewController: NSViewController, NSComboBoxDelegate, NSComboBoxDataSource {
@IBOutlet weak var combo: NSComboBox!
var dataSource: [String] = ["Off"]
override func viewDidLoad() {
super.viewDidLoad()
for index in 1...512 {
dataSource.append("\(index)")
}
combo.reloadData()
combo.selectItem(at: 0)
}
func comboBox(_ comboBox: NSComboBox, objectValueForItemAt index: Int) -> Any? {
return dataSource[index]
}
func numberOfItems(in comboBox: NSComboBox) -> Int {
return dataSource.count
}
}
According to Apple documentation here the dropdown should show the selected item: Apple NSComboBox Docs