Skip navigation
Currently Being Moderated

New CS4 features

Oct 19, 2008 10:42 AM

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
 
Replies
  • Currently Being Moderated
    Nov 6, 2008 8:13 PM   in reply to Harbs.
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 6, 2008 11:15 PM   in reply to Harbs.
    Apologies for misspelling your name, Harbs. I always try to do better than this and feel terrible about the error.
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 1:47 AM   in reply to Harbs.
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 2:37 AM   in reply to Harbs.
    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
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 4:53 AM   in reply to Harbs.
    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
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 9:06 AM   in reply to (Simon_Paterson)
    > 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
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 11:00 AM   in reply to Harbs.
    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
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 12:05 PM   in reply to Peter Kahrel
    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
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 12:18 PM   in reply to Harbs.
    > 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
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 7, 2008 4:10 PM   in reply to Harbs.
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 8, 2008 1:37 AM   in reply to Harbs.
    >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
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 11, 2008 1:04 AM   in reply to Harbs.
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2008 8:19 AM   in reply to Harbs.
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2008 3:20 PM   in reply to Harbs.
    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.)

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2008 4:04 PM   in reply to Harbs.
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 11, 2008 1:03 AM   in reply to Roy McCoy
    [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
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 11, 2008 2:04 AM   in reply to Harbs.
    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();
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 11, 2008 5:49 AM   in reply to [Jongware]
    because we use NewsReader (I use ThunderBird) - not WebBrowser

    robin

    --
    www.adobescripts.com
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 11, 2008 9:07 AM   in reply to Harbs.
    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
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 11, 2008 10:29 AM   in reply to Roy McCoy
    yes :) now is fine :)

    robin

    --
    www.adobescripts.com
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 11, 2008 11:58 AM   in reply to Roy McCoy
    Attaboy! Thank you very much.
    --
    Noel
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 18, 2008 9:30 PM   in reply to Harbs.
    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
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)