Following this question and the documentation example. I tried to implement a piece of code that enable and disable two buttons (Undo and Redo) in a macOS Toolbar.
override func validateToolbarItem(_ toolbarItem: NSToolbarItem) -> Bool {
var enable = false
if toolbarItem.itemIdentifier.isEqual("undoButton") {
enable = (mainTextField.undoManager?.canUndo)!
}
else if toolbarItem.itemIdentifier.isEqual("redoButton") {
enable = (mainTextField.undoManager?.canRedo)!
}
return enable
}
Unfortunately it seems that the code has not effect. What am I missing?