Copy link to clipboard
Copied
Hello,
I'm looking for a way to add custom scripts to the context menus (right click with the mouse) of the paragraph style and the character style palette.
So the user finds the style he's looking for, right clicks on it, chooses my script, the script gets the reference to the selected style item, and runs with it.
Is this possible by scripting? A forum and google search was unsuccessful.
Thanks!
Tobias
Copy link to clipboard
Copied
I modified kasyan's script (see below) to find the right KeyStrings menu name, but there seems to be none. Any ideas?
Tobias
//~ Thanks to kasyan! Base of the script can be found here:
//~ http://kasyan.ho.com.ua/open_menu_item.html
var arr = [],
appVersion = app.version,
fileName = "~/Desktop/Menus_ID-"+appVersion.replace(/\./g, "-")+".csv",
theDelim = ";";
arr.push("\""+"head:InDesign v"+appVersion+"\"");
arr.push("\""+"head:index"+"\""+theDelim+"\""+"head:KeyStrings"+"\""+theDelim+"\""+"head:name"+"\"");
for (var i = 0; i < app.menus.length; i++) {
theItem = app.menus;
arr.push("\""+theItem.index+"\""+theDelim+"\""+app.findKeyStrings(theItem.name)+"\""+theDelim+"\""+theItem.name+"\"");
}
var str = arr.join("\r");
WriteToFile(str, fileName);
function WriteToFile(text, fileName) {
file = new File(fileName);
file.encoding = "UTF-8";
file.open("w");
file.writeln(text);
file.close();
}
Copy link to clipboard
Copied
The key string should be "RtMenuStyleListItem", probably shared across all style panels.
In scripting I know of no way to access the targeted tree node - or nodes, in the styles panels you can select multiple items. A plugin could peek at the panel selection, I did that back around CS2 but had no need to maintain it since then. And I just checked, the matching app.panels object for paragraph styles still has no useful properties.
Hmm, one idea: you could eventually peek at the name of one of the other actions, e.g. kContextMenuStyleOptionsActionID that would be id=0x2123. No idea whether that would work, though.
Dirk
Copy link to clipboard
Copied
Thanks Dirk! That doesn't sound very promising. I'll take a closer look, but I'll also think about solving the matter differently. A pitty!
Tobias