1

In my NSCollectionViewItem I set up a mouseDown function, that calls a setSelected() function in the view.

override func mouseDown(with event: NSEvent) {
    (self.view as! ListTableViewCell).setHighlighted(true, animated: true, completionHandler:{
        print("completionHandler called")
        self.delegate?.collectionViewItem(self, didSelectAtIndexPath: self.indexPath!)

        super.mouseDown(with: event)
    })
}

As you can see, in the completionHandler, I then call the delegate and tell it a cell has been selected. In that delegate function I then deselect the row.

override func tableView(_ tableView: AppTableView, didSelectRowAtIndexPath indexPath: IndexPath) {
    print("didSelectRowAtIndexPath()")
    tableView.deselectRow(at: indexPath, animated: true)
    print(indexPath)
}

This code works, but when it is executed, it executes near instant making the backgroundColor change invisible. How can I animate this? Or slow it down? Or are there any other solutions?

user4992124
  • 1,574
  • 1
  • 17
  • 35
  • 1
    Is there a specific reason you do not use the default selection mechanism of the collectionView and rolling your own? Also, what is the role of the tableView in your code? – Alladinian Aug 09 '18 at 10:38

0 Answers0