1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00

GH-297 Publish double click on a buffer

This commit is contained in:
Tae Won Ha 2016-11-23 21:33:26 +01:00
parent 2ec21b1497
commit a1d127f351
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -7,6 +7,11 @@ import Cocoa
import RxSwift
import PureLayout
enum BufferListAction {
case open(buffer: NeoVimBuffer)
}
class BufferListComponent: ViewComponent, NSTableViewDataSource, NSTableViewDelegate {
fileprivate var buffers: [NeoVimBuffer] = []
@ -27,6 +32,7 @@ class BufferListComponent: ViewComponent, NSTableViewDataSource, NSTableViewDele
self.bufferList.dataSource = self
self.bufferList.delegate = self
self.bufferList.doubleAction = #selector(BufferListComponent.doubleClickAction)
}
override func addViews() {
@ -57,6 +63,20 @@ class BufferListComponent: ViewComponent, NSTableViewDataSource, NSTableViewDele
}
}
// MARK: - Actions
extension BufferListComponent {
func doubleClickAction(_ sender: Any?) {
let clickedRow = self.bufferList.clickedRow
guard clickedRow >= 0 && clickedRow < self.buffers.count else {
return
}
NSLog("double clicked: \(self.buffers[clickedRow])")
self.publish(event: BufferListAction.open(buffer: self.buffers[clickedRow]))
}
}
// MARK: - NSTableViewDataSource
extension BufferListComponent {