Make the sidebar contextual menu refer to the clicked row rather than the selected row.
This commit is contained in:
parent
d59058c014
commit
4491c5f443
|
@ -20,7 +20,7 @@ import AppKit
|
|||
|
||||
menu.removeAllItems()
|
||||
|
||||
guard let contextualMenu = sidebarViewController.contextualMenuForSelectedObjects() else {
|
||||
guard let contextualMenu = sidebarViewController.contextualMenuForClickedRows() else {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,6 @@ import AppKit
|
|||
|
||||
public func menuNeedsUpdate(_ menu: NSMenu) {
|
||||
|
||||
guard let sidebarViewController = sidebarViewController else {
|
||||
return
|
||||
}
|
||||
|
||||
// Save the first item, since it’s the gear icon itself.
|
||||
guard let gearMenuItem = menu.item(at: 0) else {
|
||||
assertionFailure("Expected sidebar gear menu to have at least one item.")
|
||||
|
@ -26,6 +22,9 @@ import AppKit
|
|||
menu.removeAllItems()
|
||||
menu.addItem(gearMenuItem)
|
||||
|
||||
guard let sidebarViewController = sidebarViewController else {
|
||||
return
|
||||
}
|
||||
guard let contextualMenu = sidebarViewController.contextualMenuForSelectedObjects() else {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -200,6 +200,19 @@ import RSCore
|
|||
return menu(for: selectedObjects)
|
||||
}
|
||||
|
||||
func contextualMenuForClickedRows() -> NSMenu? {
|
||||
|
||||
// TODO: If the clickedRow is part of the selected rows, then do a contextual menu for all the selected rows.
|
||||
|
||||
let row = outlineView.clickedRow
|
||||
guard row != -1, let node = nodeForRow(row) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let object = node.representedObject
|
||||
return menu(for: [object])
|
||||
}
|
||||
|
||||
// MARK: NSOutlineViewDelegate
|
||||
|
||||
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
||||
|
|
Loading…
Reference in New Issue