I successfully create the new entry above the division bar above the Clear Menu in the Open Recent Search… sub menu. It is enabled and correct but it is not linked the the on choose menu item event handler. I use CXcode 3.2.5.
Can anybody tell me how to link it? Thanks
-- choose the folder/disk
try
set theFolder to choose folder with prompt "Please choose a folder or a hard disk to ssearch ." default location (path to home folder)
on error e
if not e as text = "User canceled." then
log "error when choosing folder: " & e
end if
return
end try
-- do the search
doSearch(theFolder)
on doSearch(theFolder)
-- code for search here
-- do the search then save the
saveToRecent(theFolder as text)
end doSearch
on saveToRecent(stringTAdd)
set theMenu to menu 2 of main menu
set theSubmenu to menu item 2 of theMenu
set anotherMenuItem to make new menu item at beginning of menu items of sub menu of theSubmenu with properties {title:stringTAdd, name:stringTAdd, enabled:true} --,event handler:"choose menu item"}
-- set event handler of sub menu of theSubmenu to "on choose menu item"
end saveToRecent
on choose menu item theObject
log ("choose menu item " & name of theObject as text) -- & ((event handler of sub menu of menu item id 57 of sub menu of menu item id 19 of main menu))
-- nothing gets logged as the new sub menu's item is not linked to this event handler
end choose menu item