I created a custom control that uses NSMenu…
In one window it works just fine…
in another window … using the EXACT same code syntax … all the menu items are grayed out.
Normally this means that no action has been assigned to the menu item… but that is not the case, as the action is a function inside the custom control , therefore the instance on each window would be using the exact same code.
But everything is “acting” like there is no action
here is a portion of the code that adds the items,
public final func addRow(_ item : String) {
if item=="-" {
addSeparator()
} else {
let menuItem = NSMenuItem(title: item,action: #selector(self.popUpClicked(_:)),keyEquivalent: "")
menuItem.target = self // IMPORTANT, otherwise it looks into the responders chain
menuItem.isEnabled = true
zMenu.addItem(menuItem)
}
}
@objc func popUpClicked(_ sender:NSMenuItem){
if sender.title != lbl.stringValue {
lbl.stringValue = sender.title
self.delegate?.changed(self, text:text)
self.delegate?.changed(self, index:listIndex)
}
}