Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

[ID8+/JS] Context Menu Item for Paragraph and Character Style Palette

Engaged ,
Jul 17, 2015 Jul 17, 2015

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

TOPICS
Scripting
638
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 17, 2015 Jul 17, 2015

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();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 18, 2015 Jul 18, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 19, 2015 Jul 19, 2015
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines