0

I populated a NSTableView with some data, and one of the cells truncates the text.

I have searched for how to not truncate this string, but I only found resources indicating how to voluntarily truncate the text.

I fill the text like this :

extension MessagesViewController: NSTableViewDelegate {
    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {

...
...
...

    /* Set the information in a cell and return it. */
    if let lCell: NSTableCellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: lCellIdentifier), owner: nil) as? NSTableCellView {
        lCell.textField?.stringValue = lText
        lCell.imageView?.image = lImage ?? nil
        lCell.textField?.toolTip = lText
        lCell.textField?.autoresizesSubviews = true
        //lCell.textField?.
        return lCell
    }

The result I get is the following :

Unwanted behavior for the "data" cell

I want the "data" field to show the whole contents of the string. I sized the length of the column for it to fit.

Any help would be appreciated, Thanks, Clovel

Clovel
  • 58
  • 10

1 Answers1

0

So, it seems that when you have a NSTableCellView, you have to manually resize and set constraints for the NSTextField that is inside. The default values for this box seems to have set it to not fit the cell.

Beware of default values !

Clovel
  • 58
  • 10