[CS4/5] [JS] Which paragraph style does the panel context menu action work on?
Hi all,
I am trying to write something similar as http://forums.adobe.com/message/2866720#2866720 for the paragraph style context menu. I also would like to find out which paragraph style has been selected when the context menu opens. In the thread there is a "dirty" solution for this, the Edit and Apply options of the context menu also mention the name of the paragraph style. This works as long as the paragraph style is unique.
In my situation the paragraph style names are not always unique, the same name is used in different paragraph style groups. I thought of an even "dirtier" solution that might work for this. The basic idea behind this is to create a new text, asfaik Indesign will automatically apply the active paragraph style to this text and it is easy to grab this style. The code for this is below:
var myDoc = app.activeDocument;
var myTextFrame = myDoc.textFrames.add();
myTextFrame.contents = "grab the paraStyle";
var myParaStyle = myTextFrame.paragraphs[0].appliedParagraphStyle;
myTextFrame.remove();
In my situation this approach seems to work fine but I am wondering if there is something against creating a new textframe and removing it later? And will the new text always get the current selected paragraph style?
Best Regards,
Bill