【问题标题】:select outlineView row with nsbutton使用 nsbutton 选择 outlineView 行
【发布时间】:2017-08-24 13:17:47
【问题描述】:

我使用 swift 4 for osx。 我有带有自定义单元格的 nsoutlineview。 每个单元格中都有一个按钮。

在我的 outlineView-Controller-Class 中是这个按钮的 IBAction 动作:

@IBAction func showInfo(_ sender: NSButton) {     

   // Get the row of clicked button
   print(myOutlineView.row(for: sender as NSView))

}

但我也想选择此按钮所在的行。 我想我必须使用这个命令:

myOutlineView.selectRowIndexes(<NSIndexSet>, byExtendingSelection: <Bool>)

但是我怎样才能得到 NSIndexSet 的值呢?

【问题讨论】:

    标签: swift macos cocoa nsoutlineview


    【解决方案1】:

    好的,我找到了解决方案:

    myOutlineView.selectRowIndexes(IndexSet(integer: myOutlineView.row(for: sender as NSView)), byExtendingSelection: false)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多