What happens if you refer to the menu item by name? As in:
set title of menu item "myOwnMenuItem" of sub menu of menu item
"firstMainMenuItem" of main menu to myOwnTextVariable
An NSReceiverEvaluationScriptError: 4 usually occurs when an element
you are referring to can not be found. In such cases I always try to
get to the bottom of things like this:
try
set mainMenu to main menu
get mainMenu
on error errorMessage
error "Could not get main menu: " & errorMessage
end try
try
set firstMainMenuItem to menu item "firstMainMenuItem" of mainMenu
get firstMainMenuItem
on error errorMessage
error "Could not get first main menu item: " & errorMessage
end try
try
set subMenu to sub menu of firstMainMenuItem
get subMenu
on error errorMessage
error "Could not get sub menu: " & errorMessage
end try
try
set menuItem to menu item "myOwnMenuItem" of subMenu
get menuItem
on error errorMessage
error "Could not get menu item: " & errorMessage
end try
If this does not work I can only give you the advice to put trivial
code like this into a try block and log the error that occurs to a
file or the run log if you're running the application from Xcode. The
user should not see errors like this, at least not if renaming the
menu item is absolutely necessary and the application couldn't go on
without it.
Adrian
On Jan 13, 2006, at 12:35 AM, Philip Aker wrote:
On 2006, Jan 12, at 12:28, David Hanauer wrote:
set title of menu item 2 of sub menu of menu item 1 of main menu
to myOwnTextVariable
Try 'memu bar item'. Other than that, I wouldn't know.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-studio/lists%
40macevangelist.de