24 Replies Latest reply: Dec 19, 2008 12:52 AM by Harbs. RSS

    New CS4 features

    Harbs. MVP
      At Dave's suggestion, I'm starting a thread for discussing new scripting
      features is CS4. I'd divide new features into three categories: 1)
      improvements/additions to the InDesign DOM, 2) improvements to the ESTK,
      and 3) improvements/additions to ScriptUI.

      I'll start off this thread with one improvement on each of these fronts.
      (There are lots...)

      Category 1:
      There's a new isValid property for all InDesign objects. This is
      something that's been in the SDK for ever, but only made its way into
      the scripting DOM of CS4. This means that instead of try/catch every
      time you're trying to figure out if an object is valid, you can just write:
      if(myObject.isValid){DoMyStuff()}

      or,
      if(! myObject.isValid){return}

      This is a small thing but in my book it's huge!

      Category 2:
      There's a new function panel in the ESTK which shows all the functions
      in the current script and makes navigating to the functions very easy.

      Category 3:
      There are now keyboard and mouse events, so you can now create widgets
      which do everything the built in dialog scripting widgets do (and a
      whole lot more!!!)

      --
      Harbs
      http://www.in-tools.com
        • 1. Re: New CS4 features
          (Simon_Paterson)
          Thanks, Habs. This is great. Has whet my appetite.

          Wondering if you could satisfy a few curiosities I have.

          Scripting DOM queries:

          1. width and height property on page items?
          2. shortcuts (ability to set through a script)?
          3. cap height and x-height properties of text objects?

          ESTK queries:

          1. Has the UnitValue object been expanded to use agates?
          2. When you have an object (or array) disclosed in the object viewer and you step through a script in debug mode, does the object still un-disclose? That is, if you are looking at the properties of an object each time you step over a line in the script that object would close up (at least on PPC Mac) ESTK2. Has this behaviour changed? (I find this particularly annoying: I often want to watch the value of object properties change as I step through a script and each step the object would close and I would have to re-open.)

          ScriptUI queries:

          1. Is there a tab view?
          2. Is there a table view?
          3. Is there an enabling group (as in InDesign UI)?

          None of these things are a huge deal, but my curiosity has the better of me so I feel compelled to ask.
          • 2. Re: New CS4 features
            (Simon_Paterson) Community Member
            Apologies for misspelling your name, Harbs. I always try to do better than this and feel terrible about the error.
            • 3. Re: New CS4 features
              [Jongware] MVP
              Cat. 1:

              >app.activeScriptUndoMode

              Four nice possibilities.

              >(any text object).characterDirection

              Finally, a working RTL option -- but not in the UI!? (I haven't tried it yet.)

              >(some print preferences).Screeening

              It's a screeeam. At least it's spelled consequently all throughout the help.
              • 4. Re: New CS4 features
                pkahrel MVP
                Hello Jongware,

                RTL is in fact fully functional in CS4. Though you can't see it in the interface, you can script it. First, there's a new composer, "Adobe World-Ready Paragraph Composer". Then there are a number of properties (and enumerations) to deal with RTL, such as paragraphDirection, characterDirection, and diacriticPosition. There are several more, they are highlighted in http://www.kahrel.plus.com/indesign/id6-dict.pdf (together with all other new CS4 script methods/properties/enumerations).

                CS4's RTL features are available *only* through scripting, which makes it a bit of an abstract affair (though the RTL features become visible in the UI's paragraph-style panel once you've created an RTL paragraph style and set some RTL features). None of it is documented, so we're on our own here -- but you'll get used to it! Anyway, it's great that in CS4 we can process Arabic, Hebrew, and other complex-script languages.

                By way of example, here's a script that creates an RTL paragraph and sets a few properties:

                create_RTL_paragraph (app.activeDocument, 'RTL');
                

                function create_RTL_paragraph (doc, stylename)
                   {
                   if (doc.paragraphStyles.item (stylename) == null)
                      doc.paragraphStyles.add ({name: stylename});
                   var ps = doc.paragraphStyles.item (stylename);
                   ps.composer = "Adobe World-Ready Paragraph Composer";
                   ps.paragraphDirection = ParagraphDirectionOptions.rightToLeftDirection;
                   ps.characterDirection = CharacterDirectionOptions.rightToLeftDirection;
                //   ps.paragraphJustification = ParagraphJustificationOptions.arabicJustification;
                //   ps.diacriticPosition = DiacriticPositionOptions.opentypePosition;
                   }


                Peter
                • 5. Re: New CS4 features
                  pkahrel MVP
                  Here's an overview of all properties and enumerations dealing with right-to-left scripting: http://www.kahrel.plus.com/indesign/cs4-right_to_left.pdf

                  Peter
                  • 6. Re: New CS4 features
                    Community Member
                    > Scripting DOM queries:
                    >
                    > 1. width and height property on page items?

                    Don't know.


                    > 2. shortcuts (ability to set through a script)?

                    Yes.


                    > 3. cap height and x-height properties of text objects?

                    Don't know.


                    > ESTK queries:
                    >
                    > 1. Has the UnitValue object been expanded to use agates?

                    No.


                    > 2. When you have an object (or array) disclosed in the object viewer and you step through a script in debug mode, does the object still un-disclose? That is, if you are looking at the properties of an object each time you step over a line in the script that object would close up (at least on PPC Mac) ESTK2. Has this behaviour changed? (I find this particularly annoying: I often want to watch the value of object properties change as I step through a script and each step the object would close and I would have to re-open.)

                    Objects stay open now. Welcome to the 21st Century, ESTK!


                    > ScriptUI queries:
                    >
                    > 1. Is there a tab view?

                    Yes. Looks good. Haven't tried it yet.


                    > 2. Is there a table view?
                    Not yet.


                    > 3. Is there an enabling group (as in InDesign UI)?

                    Don't know.

                    -X
                    • 7. Re: New CS4 features
                      pkahrel MVP
                      Simon,

                      >1. width and height property on page items?

                      No.
                      >2. shortcuts (ability to set through a script)?

                      Unfortunately not.

                      >3. cap height and x-height properties of text objects?

                      No.

                      >ScriptUI queries:
                      >1. Is there a tab view?

                      Yes, see this example. This is a useful addition.
                      w = new Window ('dialog');
                      
                         tpanel = w.add ('tabbedpanel');
                            t0 = tpanel.add ('tab', undefined, 'Tab 0');
                               c00 = t0.add ('checkbox', undefined,'Checkbox 0 in tab 0');
                               c01 = t0.add ('checkbox', undefined,'Checkbox 1 in tab 0');
                               c01 = t0.add ('checkbox', undefined,'Checkbox 2 in tab 0');
                            t1 = tpanel.add ('tab', undefined, 'Tab 1');
                               c10 = t1.add ('checkbox', undefined,'Checkbox 0 in tab 0');
                               c11 = t1.add ('checkbox', undefined,'Checkbox 1 in tab 1');
                               c12 = t1.add ('checkbox', undefined,'Checkbox 2 in tab 2');

                         buttons = w.add ('group');
                            buttons.alignChildren = ['right', 'bottom']
                            buttons.orientation = 'row';
                            okButton = buttons.add ('button', undefined, 'OK');
                            buttons.add ('button', undefined, 'Cancel');

                         if (w.show () == 1)
                            {
                            $.writeln ("Selected panel on exit: " + tpanel.selection.text);
                            }


                      >2. Is there a table view?

                      Not sure what you mean.

                      >3. Is there an enabling group (as in InDesign UI)?
                      Yes (has been there for a while): myGroup.enabled = true/false

                      Peter
                      • 8. Re: New CS4 features
                        Community Member
                        Peter Kahrel wrote:

                        > No.
                        >
                        > 2. shortcuts (ability to set through a script)?
                        >
                        >
                        >
                        >
                        > Unfortunately not.


                        From 'Control Object Properties'

                        shortcutKey String The key sequence that invokes the onShortcutKey callback
                        for this element (in Windows only).


                        -X
                        • 9. Re: New CS4 features
                          pkahrel MVP
                          > From 'Control Object Properties'
                          >
                          > shortcutKey String The key sequence that invokes the onShortcutKey callback for this element (in Windows only).

                          Ah -- right. I thought Simon was after scripting the keyboard shortcuts, the ones you set in the UI at Edit > Keyboard Shortcuts.

                          Peter
                          • 10. Re: New CS4 features
                            (Simon_Paterson) Community Member
                            Peter, xbytor,

                            Thank you for answering my questions.

                            xbytor,

                            I was actually talking about Edit > Keyboard Shortcuts. I was crossing my fingers for that one.

                            Peter,

                            Thanks so much for the tab view example code. Very cool.

                            An 'Enabling Group' is not the same as 'enabling a group'. It is a specific type of grouping panel with a title and a tick box. Clicking the tick box enables or disables the group. A table view is a bit like a list view but with multiple columns.

                            It's great that we are starting to get some details coming through. Thanks, guys.
                            • 11. Re: New CS4 features
                              pkahrel MVP
                              >An 'Enabling Group' is not the same as 'enabling a group'.

                              Ah, I see what you mean. No, scriptUI doesn't seem to have a JS-style enabling group. You could probably fake it in scriptUI. There's good documentation on scriptUI in (ESTK 3) Help > JavaScript Tools Guide CS4.

                              Peter
                              • 12. Re: New CS4 features
                                (Simon_Paterson) Community Member
                                In the Extend Script ScruitUI documentation for CS4 it says the list view now has columns, so that it is a kind of table view.
                                • 13. Re: New CS4 features
                                  [Jongware] MVP
                                  Add to the list Of Things You Cannot Do Without Scripting:

                                  otfStylisticSets already was available as a text property in CS3; now, in CS4 you also have otfStylisticAlternate, which selects the 'salt' feature of your current font. The weird thing is, in the User Interface you
                                  i cannot
                                  select this! (Equally weird is it
                                  i is
                                  recognized in character and paragraph styles. That means that, as soon as you have used the feature in your document, you can use it in char & par definitions.)

                                  You can use Adobe Garamond Pro to test -- it has 'salt' variants for Q, a, e, n, r, t, and z. The 't' has 2 'salt' alternates, but I cannot figger out how to get the second.
                                  • 14. Re: New CS4 features
                                    Roy McCoy Community Member
                                    But how can you use the "salt" feature in char & par definitions if it isn't selectable in the UI? Does it somehow become selectable after you've scripted it into existence in your doc, or what? If you can (initially?) only use it by scripting, I would suppose you could immediately script it into char & par definitions. Sorry if I'm being dumb, but I've never used these alternates and would like to know how to. Thanks.


                                    On Dec 10, 2008, at 5:19 PM, jongware wrote:

                                    otfStylisticSets already was available as a text property in CS3; now, in CS4 you also have otfStylisticAlternate, which selects the 'salt' feature of your current font. The weird thing is, in the User Interface you   cannot  select this! (Equally weird is it   is  recognized in character and paragraph styles. That means that, as soon as you have used the feature in your document, you can use it in char & par definitions.)

                                    • 15. Re: New CS4 features
                                      [Jongware] MVP
                                      I used a script to insert it into live text (which enables it in "New Character Style"), but I think your second idea -- insert it with a script right into a paragraph or character style -- works just as well. You cannot switch it off or on without using a script -- it doesn't appear in the UI (Peter Kahrel's World Paragraph Composer option does).

                                      I'll try in the morning, shouldn't be too hard. Anyone in other time zones is invited to beat me to it.
                                      • 16. Re: New CS4 features
                                        Ildhund Community Member
                                        [OT] Roy, there's something funny with your posting settings. It
                                        looks like AppleMail or Gmail or something is trying to send HTML
                                        instead of plain text whenever you quote anything in your posts, so
                                        all this newsreader user sees is one long line of HTML tags
                                        interspersed with a bit of text now and again. This makes reading
                                        your posts very difficult - can you do something about it?
                                        --
                                        Noel
                                        • 17. Re: New CS4 features
                                          [Jongware] MVP
                                          Noel, nothing wrong with Roy's posts for me (using the default web interface). It may just be you :-)

                                          Talking about interfaces, please don't comment on this one. It does the job, innit? (I'm sure someone else could do better with ScriptUI. Go ahead.)

                                          var myStyleList = new Array;
                                          

                                          for(c = 1; c < app.activeDocument.paragraphStyles.length; c++)

                                          {

                                          if (app.activeDocument.paragraphStyles.item(c).otfStylisticAlternate == true)

                                            name = "[+] ";

                                          else

                                            name = "[-] ";

                                          name += app.activeDocument.paragraphStyles.item(c).name;

                                          myStyleList.push(name);

                                          }

                                          var myCharsList = new Array;

                                          for(c = 1; c < app.activeDocument.characterStyles.length; c++)

                                          {

                                          if (app.activeDocument.characterStyles.item(c).otfStylisticAlternate == true)

                                            name = "[+] ";

                                          else

                                            name = "[-] ";

                                          name += app.activeDocument.characterStyles.item(c).name;

                                          myCharsList.push (name);

                                          }

                                          var parDialog = app.dialogs.add({name:"Salt your Styles",canCancel:true});

                                          with(parDialog)

                                          {

                                          with(dialogColumns.add())

                                          {

                                            with(dialogRows.add())

                                            {

                                             parCheck = checkboxControls.add({staticLabel:"Paragraph style"});

                                             parDropdown = dropdowns.add({stringList:myStyleList, selectedIndex:0});

                                            }

                                            with(dialogRows.add())

                                            {

                                             charCheck = checkboxControls.add({staticLabel:"Character style"});

                                             charDropdown = dropdowns.add({stringList:myCharsList, selectedIndex:0});

                                            }

                                          }

                                          }

                                          var result = parDialog.show();

                                          if (result)

                                          {

                                            if (parCheck.checkedState)

                                             app.activeDocument.paragraphStyles.item(parDropdown.selectedIndex+1).otfStylisticAlternate =

                                              !app.activeDocument.paragraphStyles.item(parDropdown.selectedIndex+1).otfStylisticAlternate;

                                            if (charCheck.checkedState)

                                             app.activeDocument.characterStyles.item(charDropdown.selectedIndex+1).otfStylisticAlternate =
                                              !app.activeDocument.characterStyles.item(charDropdown.selectedIndex+1).otfStylisticAlternate;

                                          }

                                          parDialog.destroy();
                                          • 18. Re: New CS4 features
                                            Harbs. MVP
                                            jongware@adobeforums.com wrote:
                                            > Noel, nothing wrong with Roy's posts for me (using the default web interface). It may just be you :-)
                                            >

                                            It comes through with the garbage by me too. (using Thunderbird)

                                            --
                                            Harbs
                                            http://www.in-tools.com
                                            • 19. Re: New CS4 features
                                              Community Member
                                              because we use NewsReader (I use ThunderBird) - not WebBrowser

                                              robin

                                              --
                                              www.adobescripts.com
                                              • 20. Re: New CS4 features
                                                Roy McCoy Community Member
                                                Noel Burgess wrote:

                                                > [OT] Roy, there's something funny with your posting settings. It
                                                > looks like AppleMail or Gmail or something is trying to send HTML
                                                > instead of plain text whenever you quote anything in your posts, so
                                                > all this newsreader user sees is one long line of HTML tags
                                                > interspersed with a bit of text now and again. This makes reading
                                                > your posts very difficult - can you do something about it?

                                                I now have my Apple Mail settings at Plain Text rather than Rich Text,
                                                with "Use the same message format as the original message" checked
                                                under "Responding". Hope that helps.


                                                Roy
                                                • 21. Re: New CS4 features
                                                  Community Member
                                                  yes :) now is fine :)

                                                  robin

                                                  --
                                                  www.adobescripts.com
                                                  • 22. Re: New CS4 features
                                                    Ildhund Community Member
                                                    Attaboy! Thank you very much.
                                                    --
                                                    Noel
                                                    • 23. Re: New CS4 features
                                                      Steven.. Community Member
                                                      Now that Right To Left can be scripted, I created an Windows application with Indesign palette style UI which does the work for you check it out on my Web Site http://sites.google.com/site/adoberighttoleft/Home it's only $20.

                                                      Steven F. Bryant
                                                      http://sites.google.com/site/adoberighttoleft
                                                      • 24. Re: New CS4 features
                                                        Harbs. MVP
                                                        And here's my solution...
                                                        http://www.in-tools.com/plugin.php?p=8

                                                        --
                                                        Harbs
                                                        http://www.in-tools.com