Disable menu items on ApplescriptObjc
I am coding with ApplescriptObjc.
I want to disable a menu item "Preference..." in a function, but I can't
do it.
I can disable buttons. Here is the code:
myButton's setEnabled_(false)
So I tried to disable a menu item like a button:
myMenuItem's setEnabled_(false)
I looked at an Apple Reference
(https://developer.apple.com/library/mac/documentation/cocoa/reference/ApplicationKit/Protocols/NSMenuValidation_Protocol/Reference/Reference.html),
but I couldn't use this reference because I don't understand how to
disable it indeed.
- (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;
}
I thought I can use this function in this way:
on validateMenuItem_(myMenuItem)
if myMenuItemIsEnabled = true then
return true
else
return false
end validateMenuItem_
But this doesn't work (no response). How can I disable menu items?
No comments:
Post a Comment