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:
parent
2ec21b1497
commit
a1d127f351
@ -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 {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user