On Jan 14, 2013, at 9:12 AM, I wrote: There are two distinct problems here. I've solved one and think I know how to solve the other.
I will let you know about the other problem when I've finished testing it.
I tried what I thought would be a simple fix, but encountered some problems. The fix isn't simple. Here's how it went …
The Main.app contains, in Contents/Resources/ an application named "menuItem.app" whose original script was ...
on run tell application "Finder" set hostAppl to (container of container of container of (path to me)) as text end tell try launch application hostAppl tell application hostAppl to someMenuItemHandler() on error errText number errNr activate me "MenuItem Error = " & errNr & return & errText tell me to display dialog the result buttons {"OK"} default button 1 end try end run -----------------------------
The launch application command won't work here because of the 'run' error. (Main.app has a run handler.) I tried changing the menuItem.app script to …
on run tell application "Finder" set hostAppl to (container of container of container of (path to me)) as alias end tell try set menuItemScript to load script hostAppl tell menuItemScript to someMenuItemHandler() on error errText number errNr activate me "MenuItem Error = " & errNr & return & errText tell me to display dialog the result buttons {"OK"} default button 1 end try end run -----------------------------
This worked on one of the simpler menu items, but it does not work in general.
The handler someMenuItemHandler() calls other handlers which contain the line …
set selfRef to (path to me)
but this returns the correct path only if 'me' refers to the hostAppl. But in the script, above, the host code has been moved into menuItem.app and now returns the wrong path. Unfortunately, someMenuItemHandler must also work when called by Main.app, so I can't modify the code in Main.app.
The only alternative for a work-around seems to be to copy the handlers I need into menuItem.app and modify them to work properly there.
This is becoming a mess. I hope Apple fixes the launch application bug soon, but I can't afford to wait.
|