0

I am very new to the macOS environment. I am detecting a click in NSTableView using this method.

  func tableView(tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
}

Which works well and fine, but the problem is that when I click on the first time the tableView call this method and performs the corresponding action, when I click second time on the row, this method is not getting called. Something strange happening.

You guys have any thoughts? Do I have to deselect rows? I tried deselecting a row and deselecting all rows in this method, but that didn't help me. I am using a view based tableView

  • Do you need the rows to be selected? If not, you may return `false` from the function. – Stan Sidel Jul 12 '16 at 04:36
  • Actually that method is used to tell the table view which row can be selected by returning `true` or `false`. – vadian Jul 12 '16 at 04:39
  • So which method should I use for detecting a click on tableView row, I don't want the row to be selected. –  Jul 12 '16 at 04:47

1 Answers1

0

You may return false in your function:

func tableView(tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
   print("Should select row: \(row)")
   return false
}

There's a more elegant and correct solution in this answer. It's more work, but I'd recommend going that way.

Community
  • 1
  • 1
Stan Sidel
  • 479
  • 6
  • 18