[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

I finetuned the snippet above a bit further. In some cases the context menu will be activated (right mouseclick) from a style that is not currently selected. In thoses cases the example above doesn't give the correct information. In order to avoid this I am now applying the paragraph style of the current context menu to an intermediate textframe. The snippet below is placed inside the EventHandler of my custom context menu item.
var myDoc = app.activeDocument;
//store current selection
var mySelection = myDoc.selection;
//create intermediate textframe
var myTextFrame = myDoc.textFrames.add();
myTextFrame.contents = "grab the paraStyle";
myTextFrame.select();
//apply the para style of the context menu to the intermediate text
var contextMenu = app.menus.item("Text Style List Context Menu"); //or "$ID/RtMenuStyleListItem"
var applyMenuItem = contextMenu.menuItems.itemByID(8488).associatedMenuAction; //Apply "para style for context menu"
applyMenuItem.invoke();
//grab the para style of the context menu
var myParaStyle = myTextFrame.paragraphs[0].appliedParagraphStyle;
//restore original selection and remove intermediate textframe
myDoc.selection = mySelection;
myTextFrame.remove();
Again this snippet seems to work fine. I realize this approach will only work for para styles in a Document object and not for default para styles defined in the Application (suggestions to solve this?). A further refinement could be to first check if a para style name is unique, if that is the case the solution of Jongware (see http://forums.adobe.com/message/2861568#2861568) can be used and an intermediate textframe is not required.  
I know this is a dirty solution but are there any issues with this approach?

Similar Messages

  • How can i give multiple paragraph styles on the same line

    i want to give different paragraph style in the same line in an indesign document. bt when i tried it, it is coming in two different line.
    actually i am doing a project in which Frame maker document is transformed into indesign document. in frame maker this is possiable, but in indesign i cannot give different paragraph style in the same line of the document.
    Is there any way to do this ????

    YaneshTyagi wrote:
    i want to give different paragraph style in the same line in an indesign document. bt when i tried it, it is coming in two different line.
    actually i am doing a project in which Frame maker document is transformed into indesign document. in frame maker this is possiable, but in indesign i cannot give different paragraph style in the same line of the document.
    Is there any way to do this ????
    Hi, Yanesh:
    Please understand, the FrameMaker feature known as a run-in paragraph, which is a paragraph with a "carriage return" but without a "line feed," HAS NO COUNTERPART in InDesign. InDesign also lacks the FrameMaker side heading feature, which is created by the combination of a reserved area in the text frame and the paragraph property to inhabit that area. FrameMaker separates paragraphs by using the larger of space below paragraph and space above paragraph, but InDesign separates paragraphs by adding the space below paragraph and the space above paragraph.
    There are several complicated manual methods of simulating these FrameMaker properties in InDesign.
    Here's a recent forum discussion of these exact issues: http://forums.adobe.com/message/3759635#3759635. The thread mentions DTP Tools' conversion tool, the MIF Filter commercial plug-in for InDesign, and discusses its shortcomings. I don't recall it mentioning in-tools.com plug-ins that can simulate side headings, like those in FrameMaker, but they don't convert FrameMaker to InDesign. 
    You can add your vote for InDesign's developers to include these FrameMaker features, and any others you'd like to see, here: wish.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • How do I stop ID from assigning a paragraph style to the TABLES?

    In-Design is adding "H1" paragraph style to EVERY table is inserted, so the table headers formatting is affected by that H1 style.
    I guess it chooses H1 because it's the FIRST style I created (and then modified the "basic paragraph" to modify the rest of default text).
    It's like it's adding "Style_ID=1"
    I tried placing the character in different places, to make sure it's not the style the cursor is in which is inherited, and no, no matter where I place the cursor, when I "insert table" the cursor is automatically placed into the first cell (header cell) and the paragraph "H1" is selected (and applied)
    Adding a table with NO headers does the same, so it's not me that confused style names and applied some to the wrong place.
    H1 is not used and table and cells styles are not based in it.
    I don't know whether it's a bug, but IT FEELS like a bug.
    How do I expect it to work?
    I expect that by creating a table, NO style be applied other than the table's. (Not even the basic one)

    You might have set the default paragraph style for the document (which you set by selecting a paragraph style with no text frame selected) to your H1 paragraph style.
    Make sure it's on "Basic paragraph" when you select the type tool..

  • How do I access *load paragraph styles* from the styles pallet menu?

    Adobe help informs me that I can bring styles from other documents into an existing document by doing this:
    "To copy paragraph styles from one publication to another choose Load Paragraph Styles from the Paragraph Styles panel menu."
    I do not see any menu in the paragraph style menu. I am in CS5. What am I missing?

    I'm sorry, I found it. I had to go back to my G4 and the CS version to see what to do. I did not recognize the small feature on the window yielding the menu.

  • Which SIM card does the iPad mini take? Does it have to be specific type of SIM for the iPad mini?

    Which SIM card does the iPad mini take? Does it have to be specific type of SIM for the iPad mini?

    Welcome to the Support Communities. The answer to your question is available in Apple's website — see the Input/Output section here:
    http://www.apple.com/ipad-mini/specs/

  • Which application area does the SHOP VISIT NOTIFICATION cover under..

    which application area does the SHOP VISIT NOTIFICATION cover under..
    if possible pass me some useful information reg this SVN.
    i require this information very urgent...

    Ok, I think I'm on the right track now. I was finally able to inspect the HTTP requests coming in to my destination page, and I do see the notification post coming in, with the expected form data. Here's a sample of the HTTP request that came in after submitting a new quote on my site, in case anyone's interested.
    JSON:
    {"connection":"keep-alive", "content-length":"32", "content-type":"application/x-www-form-urlencoded", "host":"notification.azurewebsites.net", "max-forwards":"10", "x-liveupgrade":"1", "x-original-url":"/", "x-forwarded-for":"192.150.2.7:17242", "x-arr-log-id":"ae52537a-df3b-4bc5-a386-f652c9a03ef2"}
    { ObjectID: '4448953', ObjectType: '2008' }

  • Does the iPad Wi-Fi+3G work like the Wi-Fi model if I have no 3G data plan?

    Hi all!
    Does the iPad Wi-Fi+3G work like the Wi-Fi model if I don't have any 3G data plan subscription?

    Yes it does. Added bonus: You get GPS (which the WiFi model doesn't have but which works without a SIM card).

  • How does the Concurrent Access License (CAL) work.

    Description from Google: How does the Concurrent Access License (CAL) work? Xcelsius Engage Server CALs allow for concurrent live data updates inside Xcelsius dashboards. Every time an end-user triggers a Web service inside an Xcelsius dashboard to retrieve live data, a CAL is consumed for a period of 5 minutes. For that period, in a five CAL deployment for example, there will be only four CALs left for consumption. A five CAL deployment could support up to 25 users and additional CALs can be added to support a larger deployment.
    My question is as follows:
    How a five CAL deployment could support up to 25 users and what does it mean. In the first line it is saying that each CAL for a web service is consumed for a period of 5 minutes and how come it can support 25 users concurrently. Did it mean 25 web service connections inside a swf flash file or 25 different users to access a single web service through swf flash.

    The "Set cost controls" concurrent program is used in R12 to mass update the cost control fields on item costs.
    The cost control region is found by going to Cost management >Item costs > Item Costs
    The concurrent program lets you specify which items /costs should be updated by using various parameters such as cost type, item range, category range etc.
    And you can specify the source for the new cost control data and the new value for the fields.
    Hope this answers your question,
    Sandeep Gandhi

  • Does the new ipad 4g gps works without cell phone signal

    does the new ipad 4g gps works without cell phone signal?

    GPS has no need of a cell phone signal or wifi. The only reason you would need a data signal is to download maps to enable the GPS to show you where you are. If you installed an app which includes the mapping, for instance TomTom, you have no need for data reception.

  • Does the ipod nano 7th gen work with Belkin Blue tooth In car hands free? Customer support said it did when I bought it, but the box doesn't say it does and I dont want to open it in case I have to return it.

    Does the ipod nano 7th gen work with Belkin Blue tooth In car hands free? Customer support said it did when I bought it, but the box doesn't say it does and I dont want to open it in case I have to return it.

    If the Belkin supports the A2DP (Stereo Bluetooth) profile then it will work.

  • Does the 10.0.2 update work?

    Does the 10.0.2 update work?
    I tried the update to 10.0.2 when it was released but the update failed to work.
    Adobe Application Manager gave the following dialogue:
    "Some updates failed to install. Update is not applicable".
    Apple's Get Info for the application says version 1.0.1 and the Adobe about box says version 10.0.1.19
    I ran "updates" from the After Effects help menu again this morning but the response is "no updates available"
    I have the retail copy of CS5 and used the retail version of the update.
    Pip

    Someone's going to say it, so it may as well be me...
    This is a user-to-user group, not an official Adobe technical support outlet.  It is my understanding that Adobe people such as Todd contribute as part of an unofficial help policy, and we all appreciate the input.
    So sorry if you think these very useful fora are shoddy and didn't meet your expectations!

  • Does the Epson Expression 1600 Scanner work in SL?

    Does the Epson Expression 1600 Scanner work in Snow Leopard? Did you have to install Rosetta to get it to work?
    I use my MacBook Pro for business and it is vital that everything I use works properly. From what I've seen on these posts, I may be waiting a long while to upgrade.

    People who need to SCAN & PRINT without a compatible driver from their manufacturer can use Apple's very basic "PRINT & SCAN" utility in System Preferences:
    Click the Apple menu ( ), and then click System Preferences .
    Click Print & Scan ( ).
    Click Scan , and then click Open Scanner .
    Click Show Details . The details of the scan display, including options to modify scan settings such as output type.Figure 2: Example of the Show Details scanning screen
    Change any settings as necessary, and then click Scan .
    Hope this helps

  • How well does the wireless "Wild Charge" pad work with the iPhone?

    how well does the wireless "Wild Charge" pad work with the iPhone?

    I have tried similar things, and no, it has not become corrupted. So it should be fine

  • When and how does the message context get removed from the message when we use pass thru send port

    Friends,
    i have a doubt regarding message context.
    Assume i have used XMLRecieve pipeline in the receive side to receive the message so that the message context is created. I.e properties are promoted/written.
    now if we use pass thru transmit pipe line at send side, how and when does the message context get removed from the message?? Since pass thru does not have any stages/components, how does the message context removed and sent out a pure message to destination???
     i mean what exactly happens here to remove the context??
    Ravindar

    Thanks for the reply.
    "The Context is created by the Adapter, regardless of any Pipeline or Pipeline Component.  It has nothing to do with PassThrough vs. XmlReceive, although XmlReceive will write Promoted Properties to the existing Context,
    as can any other Component."
    yeah yeah, adapter does create some properties in context. You are right, i am aware of it. I just missed to explain it clearly. what i meant is addition of context properties will not happen if pass thru used. Thanks its clear.
    "No.  The Context already exists on the Message when it comes from the MessageBox and
    is equally available to any Component in any Stage.  The Context that hits the Pipeline is whatever was last Persisted, either by a Receive Port or Orchestration.  It is not created by the XmlAssembler (XmlTransmit)"
    You are right , the context already exists on the message while it leaves the receive port, and once it persists
    to message box the context and message context gets stored in messages in relative tables.
    Now as you said the components get the message from the last persistence, assume i have a send port(with passthru)
    subscriber and a orchestration subsrciber for this message.
    Orchestration gets the message with context right!!
    if the send sendport(with passthru) also gets message along with context, then where is this context removed/demoted
    while sending it out?.  i guess as per SAAkhlaq said,
    here sendport(with passthru) should get a pure message without context as passthru used. 
    or is it that ultimately send adapter removes the context completely?
    or is it something like biztalk run time load the context from database into cache and both orchestration and send port gets pure message, and if needed they use context from cache???
    sorry i may be troubling you, but i am confused. i hope i am not creating any nuisance with this
    post.
    Ravindar

  • Does the Pocket Projector by Brookstone work with the iphone 5?

    Does the Pocket Projector by Brookstone work with the iphone 5 ?

    I have the Brookstone DLP Pico projector. I purchased it from EBay not too long ago. It worked before with the previous version of Apples iOS. I would view netflix, youtube, and videos.. I have an iphone4.
    Now with the latest update to ios7, tried it last evening with netflix and youtube, it does not work at all! This is rediculous, restricting access to something we had access to before

Maybe you are looking for