我正在使用 ApplescriptObjc 进行编码。
我想在函数中禁用菜单项“首选项...”,但我做不到。
我可以禁用按钮。这是代码:
myButton's setEnabled_(false)
所以我试图禁用像按钮这样的菜单项:
myMenuItem's setEnabled_(false)
我查看了 Apple 参考(https://developer.apple.com/library/mac/documentation/cocoa/reference/ApplicationKit/Protocols/NSMenuValidation_Protocol/Reference/Reference.html),但我不能使用这个参考,因为我确实不明白如何禁用它。
- (BOOL)validateMenuItem:(NSMenuItem *)item {
int row = [tableView selectedRow];
if ([item action] == @selector(nextRecord) &&
(row == [countryKeys indexOfObject:[countryKeys lastObject]])) {
return NO;
}
if ([item action] == @selector(priorRecord) && row == 0) {
return NO;
}
return YES;
}
我想我可以这样使用这个功能:
on validateMenuItem_(myMenuItem)
if myMenuItemIsEnabled = true then
return true
else
return false
end validateMenuItem_
但这不起作用(没有响应)。如何禁用菜单项?