I'd like my NSTextFields to truncate their content with trailing ellipsis. I'm using these in an NSTableView. What I'm getting is tail-truncation at *word boundaries* and no ellipsis. My code is below. Line 7 sets a lineBreakMode on the cell, but that line has no effect. I could set it to .byTruncatingMiddle or any other value or delete it altogether and the NSTextField will still tail-truncate on word boundaries with no ellipsis. MacOS Sierra.
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
var view = tableView.make(withIdentifier: "cellID", owner: nil) as? NSTextField
if view == nil {
view = NSTextField(labelWithString: "")
view!.identifier = "cellID"
view!.font = NSFont.systemFont(ofSize: 12)
view!.cell?.lineBreakMode = .byTruncatingTail
}
if tableColumn?.identifier == "Foo" {
// String to tail-truncate...
view!.stringValue = "The quick brown fox jumped over the lazy dog"
}
else {
view!.stringValue = "Blah blah blah blah blah"
}
return view
}