mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-16 08:02:53 +03:00
23 lines
575 B
Swift
23 lines
575 B
Swift
// Copyright © 2021 Tokenary. All rights reserved.
|
|
|
|
import Cocoa
|
|
|
|
class RightClickTableView: NSTableView {
|
|
|
|
var deselectedRow = -1
|
|
var shouldShowRightClickMenu = true
|
|
|
|
override func menu(for event: NSEvent) -> NSMenu? {
|
|
guard shouldShowRightClickMenu else { return nil }
|
|
let point = convert(event.locationInWindow, from: nil)
|
|
let index = row(at: point)
|
|
if index >= 0 {
|
|
selectRowIndexes([index], byExtendingSelection: true)
|
|
return menu
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
}
|