Copy link to clipboard
Copied
Hi everyone,
Trying to execute a menu addition and at the moment the event handler function is executed, I get the "
var mySampleScriptAction = app.scriptMenuActions.add("Display Message");
var myEventListener = mySampleScriptAction.eventListeners.add("onInvoke",
function () { alert("This menu item was added by a script."); });
//If the submenu "Script Menu Action" does not already exist, create it.
try {
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.item("Script Menu Action");
mySampleScriptMenu.title;
}
catch (myError) {
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.add("Script Menu Action");
}
var mySampleScriptMenuItem = mySampleScriptMenu.menuItems.add(mySampleScriptAction);
Is it just me?
Loic
Hi @rob day
Yes I do use a targetengine instruction. I think the "issue" came from the fact I was doing debugging in VSCode and probably targeting a wrong enginename (thus bypassing the one declared into the script). Once run from the script palette, everything went fine indeed.
Loic
Copy link to clipboard
Copied
Hi Loic, Have you tried adding a #targetengine at the top? This works for me in CC2021:
//targetengine for listeners
#targetengine "session";
var mySampleScriptAction = app.scriptMenuActions.add("Display Message");
var myEventListener = mySampleScriptAction.eventListeners.add("onInvoke",
function () { alert("This menu item was added by a script."); });
//If the submenu "Script Menu Action" does not already exist, create it.
try {
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.item("Script Menu Action");
mySampleScriptMenu.title;
}
catch (myError) {
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.add("Script Menu Action");
}
var mySampleScriptMenuItem = mySampleScriptMenu.menuItems.add(mySampleScriptAction);
Copy link to clipboard
Copied
Hi @rob day
Yes I do use a targetengine instruction. I think the "issue" came from the fact I was doing debugging in VSCode and probably targeting a wrong enginename (thus bypassing the one declared into the script). Once run from the script palette, everything went fine indeed.
Loic