Disable clicking on FinderSync extension submenu

37 Views Asked by At

I am writing a FinderSync extension in Swift, and am creating a submenu like such:

let menu = NSMenu(title: "")
let newsub = NSMenu();
newsub.addItem(withTitle: "Folder", action: #selector(createFolder(_:)), keyEquivalent: "")
newsub.addItem(withTitle: "Empty File", action: #selector(createEmptyFile(_:)), keyEquivalent: "")
let new = menu.addItem(withTitle: "New", action: nil, keyEquivalent: "")
menu.setSubmenu(newsub, for: new)

Everything works fine but there's one very annoying quirk. In any other submenu I've tested on MacOS, if you click on the submenu line itself (so not one of its entries, but "New" in this example), nothing happens. But not for this submenu. When you click on the submenu instead of instantly expanding the submenu as normal, the context menu disappears entirely, and a clicking noise plays indicating nothing happened (as if you press an invalid hotkey).

How do I prevent this, and make the submenu non-clickable? I've tried disabling it, but that disables the submenu entirely instead of just making it non-clickable.

0

There are 0 best solutions below