Double click an NSTableView row in Cocoa?

后端 未结 8 1359
旧巷少年郎
旧巷少年郎 2020-12-13 01:41

I need my application to open a window when a user double clicks on a row in an NSTableView. I\'m having a bit of a difficult time finding information or exampl

相关标签:
8条回答
  • 2020-12-13 02:12

    Take a look at the -setDoubleAction: method on NSTableView; you can set that to a method that will be called just like the normal target-action system but on a double-click.

    In that action method, -clickedRow will be useful.

    0 讨论(0)
  • 2020-12-13 02:14

    Updated Alfred's answer for Swift 5

    @IBOutlet weak var searchResultTable: NSTableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        searchResultTable.target = self
        searchResultTable.doubleAction = #selector(doubleClickOnResultRow)
    }
    
    @objc func doubleClickOnResultRow()
    {
        print("doubleClickOnResultRow \(searchResultTable.clickedRow)")
    }
    
    0 讨论(0)
提交回复
热议问题